When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
Message Board
Related Web Technologies
User Tips!
Coding Tips

Sample Chapters
Commonly Asked Message Board Questions
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Stump the SQL Guru!
XML Info
Author an Article
ASP ASP.NET ASP FAQs Message Board Feedback
Print this page.
Comment Your Code!

  • Back to Beginner's Tip Index
  • Next tip...

    Most developers, when looking back at code they wrote just a few months ago, have a very tough time understanding what, exactly, they were doing! Part of the reason old code is tough to read is because it usually lacks sufficient commenting. In ASP (if using VBScript), you can easily comment using the apostrophe. Here is an example:

    ' Create a variable to hold the user's name
    Dim strName

    If you use JScript, you can comment using //. Here is an example:

    // Create a variable to hold the user's name
    var strName;

    The question often arises, "When should I comment?" Well, there is no such thing as "over-commenting," so if you think you should comment at a specific place, do not hesitate to do so! A general rule of thumb is to comment when dimensioning new variables, commenting any subs or functions, commenting on blocks of related code (to explain the block of code's purpose), and commenting particularly difficult or complex lines of code.

    By commenting your code thoroughly, you'll greatly increase the ease of maintainability of your ASP applications. Commenting is somewhat of a lost science, and while no one likes to take the time needed to type out comments, it does make it easier and less painful in the long run. One approach I've found helpful is to first write out the comments for an ASP page, like pseudocode, then go back and write the actual code.

  • Back to Beginner's Tip Index
  • Next tip...

  • ASP.NET [1.x] [2.0] | ASPFAQs.com | Advertise | Feedback | Author an Article