CE532
Chapter 3

3.2 PRINCIPLES OF STRUCTURED PROGRAMMING

Structured programming is a method of designing computer programs to minimize complexity (Kittner and Northcutt, 1984). Principles of structured programming are delineated in this section. Generally speaking, personal computer programs presented in this book have been developed with these principles in mind. Of course, these rules cannot always be followed rigidly, especially when efficiency or speed of computation is the major consideration.

1. The program should be "egoless", that is, easy to read and understand. Due to high manpower cost, clarity and simplicity should be valued more than complicated efficiency.

  1. Choose variable names close to standard and customary notations.
  2. Insert spaces within the program statements for better readability.
  3. Use comment statements generously throughout the program for internal documentation.
  4. Use blank statements to skip lines between blocks of the program.
  5. Indent statements within a loop.
  6. Define the variables within the program.
  7. Use one statement per line.

2. The program should be easy to modify and maintain.

  1. Use variables for constant values that may change in the future. Place the constant values at the beginning of the program.
  2. Initialize all the variables at the beginning of the program.

3. The program should be designed to maximize programmer efficiency (Kittner and Northcutt, 1984).

  1. Use top-down programming; that is, design he program in stages from simple to complex.
  2. Use a flow chart in designing the logic of the program.
  3. Avoid GOTO statements as much as possible in procedural languages such as FORTRAN and BASIC. This will prevent unnecessary complexity (the so-called "spaghetti" effect) and make the program logic easier to follow.
  4. Use modular programming. This approach will help to use fewer GOTO statements.
  5. The relationship between modules (coupling) should be weak. Each module should be as independent of the others as possible.
  6. A module should preferably have a single entry and single exit.
  7. A module should not be big in size. A good size is a singe page of coded program.

4. The program should be reliable.

  1. State the limitation of the program.
  2. Incorporate as many error messages as possible
  3. Use security to prevent modification of the program by unauthorized users.
Hojjat Adeli, Professor
Department of Civil & Environmental Engineering and Geodetic Science
The Ohio State University 
409 Hitchcock Hall, 2070 Neil Avenue, Columbus OH 43210