ASP Nuke
>
Member Login
Username
Password

Don't have an account yet, register now it's free!
I forgot my password


Article Search

Message Forums
ASP Nuke  (221/420)
ASP Development  (12/22)
SQL Server Development  (5/12)

Suggestion Box

Have a suggestion on how we can improve this application?

Please send us your suggestions, we would love to hear what you have to say!


Help ASP Nuke

Help support "ASP Nuke" and free software by donating now


Task List

ASP Nuke Tasks:


ASP Coding Standards

Orvado Technologies

Introduction

This document outlines the coding conventions we will be using when writing server-side scripting for Orvado and its clients. Specifically, it details coding standard and practiced pertaining to Microsoft's scripting language Active Server Pages or ASP for short.

Variables

Microsoft's standard coding practices encourage you to use three letter prefixes for your variable names. For our purposes, we will only use a single character prefix with no underscores in the name. The table of prefixes is shown below:

Prefix   Example   Uses
a aMonth Array of month names
b bEditMode Boolean value may be "True" or "False"
c cPriceCode Single character
d dStart Date or time value
f fAmount Floating point object (referred to as a double)
n nMonth Numeric integer type
o oDict Object created with Server.CreateObject including dictionary objects
s sFirstName All string and character data (more than one character)

For Visual Basic programmers, it is important to note that all variables in ASP have the "variant" type. It is the variant sub-type that ASP uses to manage all of its "type checking". It is this sub-type we reference with the Hungarian notation shown above.

Many ASP developers prefer to use the Microsoft recommended three letter prefix for their variable names, but I find this is often overkill for the size of the average script in ASP. There are not many sub-types commonly used in ASP programming.

Formatting

Formatting of the source code is important to ensure readability of the code. This includes how lines of code are indented relative to one another and also how whitespace is used. What follows are guidelines to use when writing or editing code.

  1. Tab size is 4 characters, no more and no less
  2. Use whitespace between all operators (1 + x) Not (1+x). Also include spaces around all Boolean operators (x <> 5) not (x<>5).
  3. Use whitespace between assignment operator (x = 1) not (x=1)
  4. Use string concatenation operator (&) to split long lines. This is especially useful when building long SQL statements.

HTML Formatting

Along with formatting the ASP code, we also need to format the HTML code that we build since it is integrated with ASP. The following standards should be applied when creating or editing files:

  1. Indent all tags between <HEAD> and </HEAD>
  2. Indent all tags between <TR> and </TR>
  3. Put all tags between <TD> and </TD> including the "TD" tags on a single line (only if the line is not too long > 80 chars)
  4. Put tags <TD> and </TD> on a line by themselves only if the content of the tags is longer than 80 characters.

Conclusion

It is hard to get a grasp of all of the coding conventions and practices we are using. If you are new to our programming practices, you should try browsing some of our scripts to understand how the code is written and how the formatting is done. You may also find it easier to take an existing script and modify it to your own purposes. I do this all the time and it saves a lot of time. We also have templates that will help you to build web scripts.

Last Updated: Sep 29, 2003

FAQ

Web Links
Download
Sponsors

Poll

What's Your Favorite Browser?

Mozilla Firefox
Internet Explorer
Netscape
Safari
Opera
Other

View Results . Archive


Other Languages

Join the language translation project  to translate ASP Nuke into other languages


Hit Counter
Total page views since
Sept 19, 2003

695083

Valid CSS!
Valid HTML 4.01!

   Never trust a computer you can't throw out a window. -- Steve Wozniak   
© 2002 Orvado Technologies, All Rights Reserved - Site Map - CSS - HTML - 23.4375 msec