WHY
USE STANDARDS?
Consistent across pages, applications, and implementations
Easier to read
Easier to maintain
Easier to reuse in other applications or implementations
AREAS
OF STANDARDIZATION
General Usage Rules
Never use ASP session variables.
Isolate as much of the application's functionality as possible into
separate functions and procedures.
Use the Commerce Co, Inc. error handling methods within each procedure.
Indenting
and Spacing
Use tabs instead of spaces to indent code
Indent all lines of code within control statements, loops, and procedures.
Do not indent the END line.
Place one blank line before and after each code block.
Place a comma and space after every item in a list.
Comments
If it takes more than a few seconds to recall what a section of
code does, add comments to explain it.
Comments should appear on their own line, not after the end of a
line of code.
Place comments directly above the line(s) of code they apply to.
Use the same indentation for both.
Fit comment lines within the horizontal viewing width of the screen.
If more than one line is needed for the comment, break it into several
lines.
A blank line should precede comments or comment paragraphs.
Comments not only can describe code function and operation, but
also other information such as tasks to-do, notes, and warnings.
Directory and File Naming Conventions
Use mixed case for directory and file names, with initial caps for
each word. SendMessage.asp
Use meaningful names for application directories so that their purpose
is apparent. OrderStatus
Use ASP names that describe the role of the page in the application.
SearchRequest.asp, SearchResponse.asp
Global
Variables
Prefix global variables with "g_"; for example, "g_objCCUserSession".
Use global variables only to store data or refer to objects that
are used by more than one procedure - Commerce Co, Inc. user session
and error objects, the user's session ID, and the XMLDOM object
if it is used in multiple procedures.
Initialize all global variable values and object references in the
Initialize subroutine
Destroy all global object references in the DeInitialize subroutine
Local Variables
Use local variables as much as possible within your procedures.
Destroy all local object references created within a procedure before
exiting the procedure
Variable
Naming
Data
Type |
Prefix |
|
Data
Type |
Prefix |
String |
str |
Currency |
cur |
Integer |
int |
Boolean |
bol |
Long |
lng |
Object |
obj |
Double |
dbl |
Date |
dat |
Single |
sgl |
XML |
xml |
Constants
Capitalize constants, and use underscores to delimit words. For
example:
Const APP_ID = "MessageCenter"
|