
CHAPTER 7
PROGRAMMING GUIDELINES
This chapter is by no means intended as an exhaustive discussion of programming techniques. It is intended simply as a guideline, primarily for the novice program- mer. For those who wish to go more deeply into the science of FORTRAN program- ming, a number of references are listed in the bibliography at the end of the chapter.
The first section of this chapter deals with general guidelines applicable to program- ming in any language. The second section lists suggestions for programming in FORTRAN specifically.
7.1 Program Development
The recommended approach to program development is the
The first step in this approach is a thorough definition of the programming task.
7.1.1 Problem Definition
Before considering any actual programming, one must understand clearly and com- pletely the problems involved. For example, a person may have to change the spark plugs on his car. This is fine, but he will be better prepared if he knows that inserting the new plugs by hand first and using a plug wrench only for final tightening reduces the possibility of stripping threads. And he will be better advised still if he is told to put a trace of
Similarly, knowing that a program must print out payroll statistics is insufficient. Is it to print out only employee names and net pay? Is it to show taxes withheld (federal, social security, state, city, ad infinitum)? Should it show other deductions for the company's stock plan, pension plan, credit union, or whatever? Should it show the hours worked, splitting out overtime, shift differential, holiday, or vaca- tion pay? Should it show accrued sick or vacation leave? And what format should be used to display all this information?
While the progammer need not state the specific algorithms to be used at this stage, he at least needs to know in detail what input the program will be receiving and in what form, and exactly what output the program is expected to produce.
7.1.2 Program Documentation
Every program should have good documentionfrom the beginning!
At the earliest stage of program development, documentation would normally be a preliminary functional specification of the program. Ideally, this specification should be reviewed by one's programming peers for constructive criticism. Not only will gaps be filled in, but this review creates an environment for exchanging theories of programming, for coworkers to familiarize themselves with each other's projects, and for developing a feeling of teamwork within a programming group.