Docsity

Coding Specifications - Introduction Applications Programming with Visual Basic | CS 405, Assignments of Computer Science

Toggle sidebar
bg1
CS405 -- Coding Specifications
8/25/09
Comments: A) Header โ€“ should conform to the following arrangement:
โ€ž Form (file): frmDemo (frmdemo.vb)
โ€ž Programmer: John Doe
โ€ž Assignment: #1
โ€ž Due Date: 11/11/11
โ€ž Description: One or more lines describing what the form/module does
B) Procedure โ€“ each procedure/function should have a descriptive comment at the top
(this should include a description of any arguments)
C) General โ€“ any significant/unusual code should be commented (above or along side)
Spacing: A) Indentation โ€“ should be consistent (Tab value of 4 recommended)
- declarations and code within a procedure should be indented one level
- code within a control structure block should be indented another level, etc
B) Lines should not be longer than your printer can handle. Use the _ continuation
character to continue on the next line (and indent each continuation line). You can use
the separator line shown in C) below as a guide to indicate the printer page width โ€“ for
example, I put the last dash in column 86, and never write code beyond that point.
C) Put a blank line, followed by a separator line, at the top of each procedure.
โ€ž------------------------------------------------------------------------------------------------------------
โ€ž This is a comment explaining what the procedure does
Private Sub btnQuit_Click() โ€ž first line of actual procedure (next line indented)
Dim intCounter As Integer โ€ž and so on
End Sub
โ€ž------------------------------------------------------------------------------------------------------------
โ€ž This is a comment explaining what the procedure does
Private Sub btnClear_Click() โ€ž first line of actual procedure (next line indented)
Dim strName As String โ€ž and so on
End Sub
D) If you declare more than two or three variables at the top of a procedure, consider
separating them from the remaining code with a blank line.
E) Do not add other blank lines to your code unless you have a justifiable reason for
doing so.
F) Remove any empty event procedures (skeletons) from your code - these usually are the
result of accidentally double-clicking on a given control in Design View, even though
you donโ€™t intend to write code for the associated event procedure.
pf2

Partial preview of the text

Download Coding Specifications - Introduction Applications Programming with Visual Basic | CS 405 and more Assignments Computer Science in PDF only on Docsity!

CS405 -- Coding Specifications

8/25/ Comments : A) Header โ€“ should conform to the following arrangement:

โ€ž Form (file): frmDemo (frmdemo.vb) โ€ž Programmer: John Doe โ€ž Assignment: # โ€ž Due Date: 11/11/ โ€ž Description: One or more lines describing what the form/module does

B) Procedure โ€“ each procedure/function should have a descriptive comment at the top (this should include a description of any arguments)

C) General โ€“ any significant/unusual code should be commented (above or along side)

Spacing : A) Indentation โ€“ should be consistent (Tab value of 4 recommended)

  • declarations and code within a procedure should be indented one level
  • code within a control structure block should be indented another level, etc

B) Lines should not be longer than your printer can handle. Use the _ continuation character to continue on the next line (and indent each continuation line). You can use the separator line shown in C) below as a guide to indicate the printer page width โ€“ for example, I put the last dash in column 86, and never write code beyond that point.

C) Put a blank line, followed by a separator line, at the top of each procedure.

โ€ž------------------------------------------------------------------------------------------------------------ โ€ž This is a comment explaining what the procedure does Private Sub btnQuit_Click() โ€ž first line of actual procedure (next line indented) Dim intCounter As Integer โ€ž and so on End Sub

โ€ž------------------------------------------------------------------------------------------------------------ โ€ž This is a comment explaining what the procedure does Private Sub btnClear_Click() โ€ž first line of actual procedure (next line indented) Dim strName As String โ€ž and so on End Sub

D) If you declare more than two or three variables at the top of a procedure, consider separating them from the remaining code with a blank line.

E) Do not add other blank lines to your code unless you have a justifiable reason for doing so.

F) Remove any empty event procedures (skeletons) from your code - these usually are the result of accidentally double-clicking on a given control in Design View, even though you donโ€™t intend to write code for the associated event procedure.

Naming : A) Objects/Controls โ€“ use standard three-character prefix, followed by descriptive name:

txtZipCode โ€“ for a textbox intended to accept a userโ€™s zipcode btnQuit โ€“ for a button that allows the user to quit the form lblLastName โ€“ for a label intended to display a last name

B) Variables โ€“ use three-character prefix, followed by descriptive name:

Dim intCounter As Integer Dim strName As String Dim dblSubTotal As Double Dim decEarnings As Decimal

The above declarations are for local (procedure-level) variables. If are variable is module-level, it should start with the letter โ€œmโ€:

Private mintCounter As Integer Private mstrName As String Private mdblSubTotal As Double Private mdecEarnings As Decimal

C) Constants โ€“ use all upper case. Because VB (internally) treats constants differently than variables, the scope issue is not as critical regarding constants. I recommend you place all your constant declarations at the top of each module (just before your module- level variable declarations).

Const MAX As Integer = 100 Const COMPANYNAME As String = โ€œJoeโ€Ÿs Pizzaโ€

D) Routines (Sub Procedures and Functions) โ€“ use as appropriate:

CalculatePay - procedure that calculates pay CheckData - procedure that checks the validity of data

Notes : A) Always place Option Strict On at the top of each form/module.

B) Be sure to label any disk you turn in as part of an assignment.

C) Staple code printouts in order.