Wednesday, March 2, 2011

PROGRAMMING PRACTICES

EVANGELINE D. TARUC BSCS IIA


1. programming readability: readability is the subjective measurement of how well code explains what it's doing. Highly readable code would be very easy for a programmer to understand without any further explanation.

- use meaningful identifiers
here is the
Dim - Dimension, declaring variables..
As Integer - data type..
intRandom As Integer,
intSum As Integer,
intCounter As Integer

- logic structure
iteration i use: For, Next..


- coding practice

Private Sub cmdGenerate_Click()
cmdGenerate.Enabled = False
cmdAdd.Enabled = True

intRandom = Rnd * 100
lblNumber.Caption = "The number is " & intRandom

End Sub

Private Sub cmdReset_Click()
intRandom = 0
intSum = 0
intCounter = 0

lblNumber = ""
lblDisplay = ""

cmdGenerate.Enabled = True
cmdReset.Enabled = False
cmdGenerate.SetFocus

End Sub






- notes and comments
I didn't use any notes and comments..

2. program documentation

- program listing
for command button:
cmdAdd.Enabled = False
cmdReset.Enabled = True
cmdGenerate.Enabled = False

for label:
lblDisplay.Caption = "The sum of 1 to " & intRandom & " is " & intSum

- program specification
I USE VISUAL BASIC 6.0

- file layouts and record description
intRandom As Integer,
intSum As Integer,
intCounter As Integer

- operating instructions
It generate, add, and reset..