Software Engineering for Students A Programming Approach
Software Engineering for Students A Programming Approach Software Engineering for Students A Programming Approach
Process header Process issue 10.4 Multiple input and output streams 129 Writing down operations, attaching them to the program structure diagram (not shown) and translating into pseudo-code, gives: open files read header record while not end of file do total = 0 read record while not end of batch do update total read record endwhile display total read header record endwhile close files Process file produce report Process batch produce total Process body Process record Process receipt Figure 10.10 Program structure diagram for processing batches Process trailer Thus we have seen that, where a program processes more than one file, the method is essentially unchanged – the important step is to see the correspondences between the file structures and hence derive a single compatible program structure. * * >
130 Chapter 10 ■ Data structure design 10.5 ● Structure clashes In a minority of problems, the two or more data structures involved cannot be mapped onto a single program structure. The method terms this a structure clash. It happens if we try to use the method to design a program to solve the following problem. Design a program that inputs records consisting of 80 character lines of words and spaces. The output is to be lines of 47 characters, with just one space between words. This problem looks innocuous enough, but it is more complex than it looks. (Have a go if you don’t agree!) A problem arises in trying to fit words from the input file neatly into lines in the output file. Figures 10.11 and 10.12 show the data structure diagrams for the input and output files. Superficially they look the same, but a line in the input file does not correspond to a line in the output file. The two structures are fundamentally irreconcilable and we cannot derive a single program structure. This situation is called a structure clash. Although it is difficult to derive a single program structure from the data structure diagrams, we can instead visualize two programs: ■ program 1, the breaker, that reads the input file, recognizes words and produces a file that consists just of words. ■ program 2, the builder, that takes the file of words created by program 1 and builds it into lines of the required width. We now have two programs together with a file that acts as an intermediary between the programs. Input file Figure 10.11 Data structure diagram for input file * Line Output file * Line Figure 10.12 Data structure diagram for output file
- Page 102 and 103: 6. Method calls with parameters tha
- Page 104 and 105: 3. Temporal cohesion 6.9 Cohesion 8
- Page 106 and 107: > } public void setY(int newY) { y
- Page 108 and 109: • Exercises 6.1 What is modularit
- Page 110 and 111: CHAPTER 7 Structured programming Th
- Page 112 and 113: 7.2 Arguments against goto 89 If we
- Page 114 and 115: ■ if-then-else ■ while-do or re
- Page 116 and 117: 7.3 Arguments in favor of goto 93 l
- Page 118 and 119: 7.4 Selecting control structures 95
- Page 120 and 121: while do if endif then else endWhil
- Page 122 and 123: • Exercises 7.1 Review the argume
- Page 124 and 125: count = 0 loop: count = count + 1 i
- Page 126 and 127: > 8.2 Case study 103 A statement th
- Page 128 and 129: start button event create defender
- Page 130 and 131: 8.3 ● Discussion Abstraction One
- Page 132 and 133: Exercises 109 skill. On the other h
- Page 134 and 135: CHAPTER 9 This chapter explains: 9.
- Page 136 and 137: 9.2 Identifying data flows 113 Noti
- Page 138 and 139: 9.3 Creation of a structure chart 1
- Page 140 and 141: SELF-TEST QUESTION 9.4 Discussion 1
- Page 142 and 143: Exercises 119 During the second sta
- Page 144 and 145: CHAPTER 10 This chapter explains:
- Page 146 and 147: In English, this reads: 10.2 A simp
- Page 148 and 149: 10.2 A simple example 125 Now comes
- Page 150 and 151: 10.4 Multiple input and output stre
- Page 154 and 155: 10.5 Structure clashes 131 As seen
- Page 156 and 157: 10.5 Structure clashes 133 Let us r
- Page 158 and 159: 10.6 Discussion 135 ■ teachable -
- Page 160 and 161: Exercises 137 2. a control block, s
- Page 162 and 163: CHAPTER 11 Object-oriented design T
- Page 164 and 165: Figure 11.1 The cyberspace invaders
- Page 166 and 167: SELF-TEST QUESTION 11.1 Derive info
- Page 168 and 169: 11.5 Class-responsibility-collabora
- Page 170 and 171: 11.7 ● Discussion Summary 147 OOD
- Page 172 and 173: 11.11 Compare and contrast the prin
- Page 174 and 175: CHAPTER 12 This chapter explains: 1
- Page 176 and 177: 12.3 Delegation 153 The concepts of
- Page 178 and 179: 12.5 Factory method 155 The followi
- Page 180 and 181: 12.8 Model, view controller (observ
- Page 182 and 183: Figure 12.4 Pipe and Filter pattern
- Page 184 and 185: Figure 12.6 Layers in a distributed
- Page 186 and 187: Answers to self-test questions 163
- Page 188 and 189: CHAPTER 13 Refactoring This chapter
- Page 190 and 191: 13.3 ● Move Method 13.6 Inline Cl
- Page 192 and 193: class Sprite Instance variables x y
- Page 194 and 195: Summary Summary 171 it is making po
- Page 196: PART C PROGRAMMING LANGUAGES
- Page 199 and 200: 176 Chapter 14 ■ The basics and a
- Page 201 and 202: 178 Chapter 14 ■ The basics > > >
Process<br />
header<br />
Process<br />
issue<br />
10.4 Multiple input and output streams 129<br />
Writing down operations, attaching them to the program structure diagram (not<br />
shown) and translating into pseudo-code, gives:<br />
open files<br />
read header record<br />
while not end of file<br />
do<br />
total = 0<br />
read record<br />
while not end of batch<br />
do<br />
update total<br />
read record<br />
endwhile<br />
display total<br />
read header record<br />
endwhile<br />
close files<br />
Process file<br />
produce report<br />
Process batch<br />
produce total<br />
Process<br />
body<br />
Process<br />
record<br />
Process<br />
receipt<br />
Figure 10.10 Program structure diagram <strong>for</strong> processing batches<br />
Process<br />
trailer<br />
Thus we have seen that, where a program processes more than one file, the method<br />
is essentially unchanged – the important step is to see the correspondences between the<br />
file structures and hence derive a single compatible program structure.<br />
*<br />
*<br />
>