Documentation Standards
Visual Basic Home Page
Use the following styles and standards in your Visual Basic programs. You may lose points on any assignment if you fail to adhere to these guidelines.
Coding
Type blank spaces around operators of all
kinds.
Example: Instead
of
intSum=intAmount+intSum
use
intSum = intAmount +
intSum
since it is much easier to read
Use consistent indentation, especially with regard to complex structures like if statements, loops, etc. Do not indent the lines in the general declarations section of a form or code module. Indent all lines inside If/Then/Else, With/End With, For/Next, Do/Loop, Select Case, Type/End Type, etc. structures for readability.
Line up inline comments where possible.
Add blank lines above and below structures such as loops and if statements. Also add a blank line below a section of code that contains variable declarations and below the remarks at the top of each procedure. Add a blank line between procedures.
Make sure that you name each form and provide a caption to each form. The most important form in your project should be named frmMain.
Follow the Windows standards, especially in relation to color, size, and placement of controls. Also, use access keys that are considered standard in Windows software (e.g. x for Exit and s for Save). Do not give two controls the same access key.
Make sure that the focus is on the correct object when a form displays. The tab order must proceed correctly when the user presses the Tab key.
Constant & variable declaration statements should always appear at the top of a procedure. Constants & variables with module-level scope must be declared in the general declarations section of the form. Global variables & constants must be declared in a code module.
Include the following information in the general declarations
section of every form in a project and the standard code module:
| Programmer Name Project/Program Name Class Period Dates Program Description Help |
' John Doe ' Program #1 ' Period 6 ' 2/03/03 - 02/05/03 ' Purpose - This program will calculate and display the number of days the user has been alive. ' Mark Schmidt helped with debugging |
If a procedure contains several major steps or functional parts, there should be comments (called signpost comments) separating the function into each major part.
Never use goto statements.
Statements which are continued on a second line must be indented further. You can use the line continuation operator ([space] _ ) to break up lines that would be cut off by the printer.
You must use the standard Visual Basic prefixes when naming objects (except for labels that never change throughout a program). Note that all object names are listed in the Form Text printout so scan that list to make sure that you have properly named all objects.
|
|
Use perfect spelling and grammar throughout your code, especially when it can be viewed by a user. If necessary, copy and paste your code into a word processor, like MS Word, and run a spell-check before you turn it in.
Documentation
Use a consistent format with regard to internal documentation. If you use complete sentences in inline comments, then do so throughout your program's code, otherwise use explanatory, understandable phrases. Remember comments are the main form of internal documentation. They should be explanatory but not too verbose (wordy). They should help explain the purpose of the program or procedure in which they are used. They should also explain the purpose of variables within specific algorithms. Always use correct spelling, punctuation, and grammar within comments.
Always include a variable dictionary to explain the purpose of each variable. That is, there should be an inline comment to the right of each variable declaration (Dim statement) and constant declaration (Const statement) that explains the purpose of the variable or constant. You can use phrases instead of complete sentences. Line up the inline comments vertically as much as possible.Variable declarations must be one per line and aligned consistently.
Follow the InterCap method for naming variables (e.g. intTotalPrice), making sure that the proper prefix (in lowercase letters) is used to identify a variable's data type or a function's return type. Programs must be "self-documenting." A program is self-documenting if its variable names imply the purposes of the variables. Variable names should be whole words or phrases that make refer to the purpose they serve within the program or function. Constants must be named with all-capital letters and underscores to separate consecutive words except for the data type prefix. For example, a module-level constant that identifies the maximum number might be named mintMAX_NUMBER.
Annotate medium to complex algorithms and assignment statements with inline comments. Do not necessarily assume that fellow programmers (or instructors) will understand your logic. However, do not document the obvious.