21.08.2013 Views

Software Engineering for Students A Programming Approach

Software Engineering for Students A Programming Approach

Software Engineering for Students A Programming Approach

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

124 Chapter 10 ■ Data structure design<br />

data structure, so all we have to do is to write “process” in every box of the data structure<br />

diagram. We thereby obtain a program structure diagram. For our program this is<br />

shown in Figure 10.5.<br />

A program structure diagram like this is interpreted as follows:<br />

■ the program as a whole (represented by the box at the top) consists of (lines leading<br />

downwards) a sequence of operations (boxes alongside one another)<br />

■ sometimes a program component is to be repeatedly executed (an “*” in the box).<br />

The next step is to write down (in any order) a list of all the elementary operations<br />

that the program will have to carry out. This is probably the least well-defined part of<br />

the method – it does not tell us how to determine what these actions should be. For<br />

the program we are working on they are:<br />

1 display n asterisks<br />

2 display blank line<br />

3 display s spaces<br />

4 increment s<br />

5 decrement s<br />

6 increment n<br />

7 decrement n<br />

8 initialize n and s<br />

9 new line<br />

Process<br />

top half<br />

Process<br />

line<br />

Process<br />

picture<br />

Process<br />

middle<br />

Process<br />

bottom<br />

half<br />

* *<br />

Process<br />

line<br />

Figure 10.5 Program structure diagram <strong>for</strong> the pattern program<br />

For later reference, we number the operations, but the ordering is not significant.<br />

Next each of these operations is placed in its appropriate position in the program<br />

structure diagram. For example, operation 2 needs to be done once, <strong>for</strong> the middle<br />

of the pattern. It is there<strong>for</strong>e associated with the box containing process middle.<br />

Similarly, operation 1 is associated with the component process line (Figure 10.6).<br />

This act of associating operations with positions is not automatic; instead, as indicated,<br />

judgment has to be employed.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!