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.

10.5 Structure clashes 131<br />

As seen by the breaker, Figure 10.13 shows the data structure diagram <strong>for</strong> the<br />

intermediate file, and it is straight<strong>for</strong>ward to derive the program structure diagram<br />

(Figure 10.14).<br />

Similarly, Figure 10.15 shows the structure of the intermediate file as seen by the<br />

second program, the builder, and again it is easy to derive the program structure diagram<br />

<strong>for</strong> program 2, the builder (Figure 10.16).<br />

Thus, by introducing the intermediate file, we have eradicated the structure clash.<br />

There is now a clear correspondence both between the input file and the intermediate<br />

file and between the intermediate file and the output file. You can see that choosing a<br />

suitable intermediate file is a crucial decision.<br />

From the program structure diagrams we can derive the pseudo-code <strong>for</strong> each of the<br />

two programs:<br />

program 1 (the breaker)<br />

open files<br />

read line<br />

while not end of file do<br />

while not end of line do<br />

extract next word<br />

write word<br />

endwhile<br />

read next line<br />

endwhile<br />

close files<br />

Intermediate<br />

file<br />

*<br />

Word<br />

Figure 10.13 Data structure diagram <strong>for</strong> the intermediate file (as seen by the breaker)<br />

Process input<br />

produce<br />

intermediate<br />

Process<br />

line<br />

Process<br />

word<br />

Figure 10.14 Program structure diagram <strong>for</strong> the breaker program<br />

*<br />

*<br />

>

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

Saved successfully!

Ooh no, something went wrong!