
Programming Guidelines |
The next pass is a more formal description of level two, introducing FORTRAN statements for English sentences.
Level Three
CINITIALIZE VARIABLES NEEDED FOR TOTALS DATA TOTEMP, TOTHRS, TOTPAY / 3*0.0/
COPEN INPUT/OUTPUT FILES, READ EMPLOYEE RECORD OPEN (input file)
OPEN (output file)
10READ (unit, 20) EMP, HRS, GRPAY, NETPAY
20FORMAT (flist)
CPRINT TOTALS IF NO MORE RECORDS IF (no more records) TH EN
WRITE (unit, 40) TOTEM P, TOTH RS, TOTPAY
40FORMAT (flist) CLOSE (input file) CLOSE (output file)
COTHERWISE PRINT EMPLOYEE DATA AND UPDATE TOTALS ELSE
WRITE (unit, 60) EMP, HRS, GRPAY, NETPAY
60FORMAT (flist)
TOTEMP = TOTEMP + 1
TOTH RS = TOTH RS + HRS TOTPAY = TOTPAY +GRPAY
CREAD NEXT EMPLOYEE RECORD GOTO 10
ENDIF END
A number of details remain to be specified, but each of these levels is in some sense complete and can be debugged to the extent that it is complete. Thus we can confirm the accuracy of the program's logic, then 110 interfaces and basic calculations, and only at the end concern ourselves with such details as format specification.
7.1.4 Final Coding
At the level of detailed code, a number of steps can be taken to simplify writing and debugging the program, or to simplify the task of another programmer updating the program later.
•Take advantage of the
•Avoid tricky programming. Code conservatively!
•Concentrate initially on making the program work. Beautiful printouts can be produced as a last step.
•Concentrate especially on getting the statement syntax correct the first time. Syntax details can be particularly annoying to FORTRAN programmers, but initial effort in this area can save a lot of grief in the long run.
•Again, use comment lines frequently. Use meaningful labels for variables. Use blanks to improve program listing readability.