Skip to main content
Lesson 8 - Structured Programming, Control Structures, if-else Statements, Pseudocode
ZIPPDF (letter)
Lesson MenuPreviousNext
  
Structured Programming page 3 of 15

  1. Up to this point in your study of computer science and Java, you have created programs that used only sequential execution. So far most programs have consisted of a sequence of lines that are executed once, line-by-line. As we add the power of loops and selection, we need to use these tools in a disciplined manner.

  2. In the early days of programming (1960's), the approach to writing software was relatively primitive and ineffective. Much of the code was written with goto statements that transferred program control to another part of the code. Tracing this type of code was an exercise in jumping from one spot to another, leaving behind a trail of lines similar to spaghetti. The term "spaghetti code" comes from trying to trace code linked together with goto statements.

  3. The research of Bohm and Jacopini1 has led to the rules of structured programming. Here are five tenets of structured programming. There are only three necessary control structures needed to write programs: sequence, selection, and iteration.

    1. No goto statements are to be used in writing code.

    2. All programs can be written in terms of three control structures: sequence, selection, and iteration.

    3. Each control structure has one entrance point and one exit point. We will sometimes allow for multiple exit points from a control structure using the break statement.

    4. Control structures may be stacked (sequenced) one after the other.

    5. Control structures may be nested inside other control structures.

  4. The control structures of Java encourage structured programming. Staying within the guidelines of structured programming has led to great productivity gains in the field of software engineering.


1Bohm, C., and G. Jacopini, "Flow Diagrams, Turing Machines, and Languages with Only Two Formation Rules," Communications of the ACM, Vol. 9, No. 5, May 1966, pp. 336-371.


Lesson MenuPreviousNext
Contact
 ©ICT 2003, All Rights Reserved.