Programming Style Guide
Programming Style Guide
Filename: ProgrammingStyleGuide.txt
Date: $Date: 2001/10/13 19:03:38 $
Version: $Revision: 1.5 $
Purpose: This document explains the style guide to be used for all code in
the Liberum Help Desk project. All developers contributing code
should follow this guide.
SECTION I: GENERAL
1. FILE NAMES
- Files should all have a three letter extension as a guide to their contents.
- An exception would be HTML files for which the extension ".html" should be
used.
2. LINE LENGTHS
- ASP documents should be no wider than 110 characters wide, to allow for extra
long lines (SQL statements, etc), except where wrapping a line might cause
syntax errors or major readability issues.
- HTML documents should be no wider than 110 characters wide, to allow for
extra long lines (SQL statements, etc), except where wrapping a line might
cause syntax errors or major readability issues.
3. INDENTATION
- Programming lines should have two extra indent in addition to that of the
previous line. This will differentiate wrapped lines with regular indentation.
4. FILE HEADERS
- The header of each file should contain the following comments (see the top
of this file for an example):
1. The standard copyright header as shown at the top of this line.
2. The filename.
3. Last edit date - use the CVS Date variable.
4. The file version - use the CVS revision variable.
5. The file's purpose.
- In ASP files this should be an ASP comment rather than an HTML comment to
save end-user download time.
5. MISCELLANOUS
- Do not use the CVS Log keyword unless it would really be useful. It makes
for some really long files!
1. LANGUAGE
2. COMMENTS
- All comments should use the standard Visual Basic / VBScript style within the
code itself, except for debugging purposes in which case use the standard HTML
comments.
- All comments should be before the line(s) they are relevent to, eg:
- Comment should be at the same indent level as the code they refer to.
3. EMBEDDED HTML
1. LANGUAGE
- All HTML pages generated should conform to the official W3C XHTML 1.0
Transitional specification.
- All HTML pages generated should have the following three lines on the top of
each page:
<?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml">
- All tags, attributes names and attribute values must be in lower case.
- All tags must have a closing tag or a " /" (a space and a forward slash)
placeholder, e.g.: <p>This is a paragraph.</p>, <img src="pic.gif" />, <hr />.
- No font tags anywhere. Use the <div> or <span> tags with the relevant CSS
code instead.
2. ACCESSABILITY
- Generated pages should not have any level 1 errors on CAST Bobby.
- Generated pages should not have any glaring level 2 errors on CAST
Bobby.
- Level 3 errors and all warnings are optional, but some of them might be worth
following.
- Do not use non-alphanumberic characters for purposes for which they are not
designed.
3. MISCELLANEOUS
- There should be no space between the <a> tag and the first character of the
next word after it; likewise there should be no space between the </a> tag and
the last word before it.
1. GENERAL
- Variables need to have a 2-4 letter prefix in lowercase that describes the
data type used.
- Variables should be lower case, except for capitalizing the start of each
word. An example would be "strFullName" or "intRecordCount".
2. VARIABLE DECLARATION
- All variables must be declared at the start of the page or procedure where
they are being used.
- All Session and Application variables must start with the prefix "lhd_" to
avoid conflicts with other IIS applications.
4. PREFIXES
- All variables should start with prefixes outlined in the table below.