By Scott Mitchell
Why Use Coding Conventions?
The primary reason to use coding conventions is to increase the readability and maintainability of your ASP code. Most developers cannot decipher their own code around six months after it has been written and last used. By religiously adhering to a strict set of coding guidelines, code is easier to read and understand.
Good code is self-documenting code. This means that your code should use variable names which reflect both their data type and purpose. Functions should have meaningful names as well. Your SQL tables and column names should be meaningful as well. For example, here is an example of hard to read code:
'Good code starts with Option Explicit
x = 4
z = 3
y = f3(f1(x) + f2(z))
One could not make heads or tails of this code without seeing the function declarations. This code could become self-documenting code with a few changes:
Dim fBase1, fBase2, fHypotenuse
fBase1 = 3
fBase2 = 4
fHypotenuse = Sqrt(Sqr(fBase1) + Sqr(fBase2))
This code is much more readable, and it is obvious that we are finding the length of the hypotenuse of a right triangle given the lengths of the two bases. The "f" prefix denotes a float, or single, variable. Ardent VB programmers may not be familiar with it, since the floating point type is not denoted float, like it is in C.
Information on ASP Coding Conventions:
ASP has its own set of recommended guidelines, and Microsoft publishes such a list at http://msdn.microsoft.com/en-us/library/ms972100.aspx.
If you take the time to follow these conventions, your code will be easier for others and yourself to maintain. In theory this should make you more marketable. (Of course there is a certain amount of job security when you write code that only you can maintain!)