Introduction to the CSD - Iteration

Iterative statements, no matter the form, are all respresented identically in the CSD: an elongated loop denotes the beginning and the end of the iterative section of code, as shown below. The figure below shows the CSD for the three types of loops found in Java, the for loop, the while loop, and the do loop.

The potential for a loop to be exited prematurely via a break condition is denoted by an arrow which points to the control level where the program should continue its execution after the loop ends. This is illustrated in the while loop below.

Additionally, should a loop contain a continue statement, an arrow is placed showing that the rest of the statements in the loop should be skipped while not exiting the loop, as demonstrated in the do loop below.


Prev Page | Next Page

Return to GRASP Documentation Page