Adding Comments in ASP

Adding Comments in ASP
Sometimes it's the simple things that confuse people. How do you add comments to your ASP code, to make it more readable and documented?

It's very easy - you just put a single quote (') at the beginning of your line of ASP. So your code might look like this -

'initialize variables'
CurrMonth = request("m")
CurrDay = request("d")

Note that I put an apostrophe before AND after my comment. You don't have to do that. But I use the TextPad editor (which I highly recommend) and it automatically highlights things based on where an apostrophe begins and ends. So by putting one on each end of my comments, I turn them all a different color.

Comments do NOT get interpreted so you can put whatever you want into them. However, while comments are important to keep track of what you are doing, I do NOT recommend putting a ton of comments into your code. Remember, your entire file has to be parsed and processed before the result is sent off to the end user. If you write War and Peace in your comments, it is going to take a while before that file gets to your end user - meaning they could give up and go elsewhere. You want your live ASP pages to be as streamlined as possible.

So I recommend putting in comments above every major block of code, so if you have to go in and debug it months later you can remember what you were doing. Maybe add a line or two at the top with the last date of change and the author's name. But leave all robust documentation separate. The primary purpose of ASP code in the end is to create a webpage for a user - and in that sense, quick action is of primary importance.




RSS
Related Articles
Editor's Picks Articles
Top Ten Articles
Previous Features
Site Map





Content copyright © 2023 by Lisa Shea. All rights reserved.
This content was written by Lisa Shea. If you wish to use this content in any manner, you need written permission. Contact Lisa Shea for details.