Structured Programming Summary
- The cost of human labor tends to rise; the cost of machinery tends to decline.
- Consequently, the best programs are those that are the simplest and clearest to humans.
- Java uses only 7 control structures:
- Sequential
- if
- if/else
- switch
- while
- for
- do/while
- These control structures are combined in only 2 ways:
- The rules for well-structured programs are:
- Begin with the "simplest flow chart" (corresponding to a 1-line pseudocode).
- Any rectangle (action) can be replaced by 2 rectangles in sequence.
- Any rectangle can be replaced by any control structure.
- Rules 2 and 3 may be applied any number of times, in any order.