Software Engineering for Students A Programming Approach
Software Engineering for Students A Programming Approach Software Engineering for Students A Programming Approach
10.6 Discussion 135 ■ teachable – people can be taught the method because it consists of well-defined steps ■ consistent – given a single program specification, two different people will come up with the same program design. ■ simple and easy to use ■ produces designs that can be implemented in any programming language. While these characteristics can be regarded as advantages, they can also be seen as a challenge to the traditional skills associated with programming. It is also highly contentious to say that data structure design is completely non-inspirational and rational. In particular, some of the steps arguably require a good deal of insight and creativity, for example, drawing the data structure diagram, identifying the elementary operations and placing the operations on the program structure diagram. Applicability Data structure design is most applicable in applications where the structure of the (input or output) data is very evident. Where there is no clear structure, the method falls down. For example, we can assess how useful this method is for designing computational programs by considering an example. If we think about a program to calculate the square root of a number, then the input has a very simple structure, and so has the output. They are both merely single numbers. There is very little information upon which to base a program structure and no guidance for devising some iterative algorithm that calculates successively better and better approximations to the solution. Thus it is unlikely that data structure design can be used to solve problems of this type. The role of data structure design Data structure design’s strong application area is serial file processing. Serial files are widely used. For example, graphics files (e.g. JPEG and GIF formats), sound files (e.g. MIDI), files sent to printers (e.g. PostScript format), Web pages using HTML, spreadsheet files and word processor files. Gunter Born’s book (see Further Reading) lists hundreds of (serial) file types that need the programmer’s attention. So, for example, if you needed to write a program to convert a file in Microsoft format to an Apple Macintosh format, data structure design would probably be of help. But perhaps the ultimate tribute to the method is the use of an approach used in compiler writing called recursive descent. In recursive descent the algorithm is designed so as to match the structure of the programming language and thus the structure of the input data that is being analyzed. The main advantages of data structure design are: ■ there is high “proximity” between the structure of the program and the structure of the files. Hence a minor change to a file structure will lead only to a minor change in the program ■ a series of well-defined steps leads from the specification to the design. Each stage creates a well-defined product.
136 Chapter 10 ■ Data structure design Summary The basis of the data structure method is that the structure of a program can be derived from the structure of the files that the program uses. The method uses a diagrammatic notation for file and program structures. Using these diagrams, the method proceeds step by step from descriptions of the file structures to a pseudo-code design. The steps are: 1. draw a diagram (a data structure diagram) describing the structure of each of the files that the program uses. 2. derive a single program structure diagram from the set of data structure diagrams. 3. write down the elementary operations that the program will have to carry out. 4. associate the elementary operations with their appropriate positions in the program structure diagram 5. transform the program structure diagram into pseudo-code. In some cases, a problem exhibits an incompatibility between the structures of two of its inputs or outputs. This is known as a structure clash. The method incorporates a scheme for dealing with structure clashes. • Exercises 10.1 Design a program to display a multiplication table such as young children use. For example, the table for numbers up to 6 is: 1 2 3 4 5 6 1 1 2 3 4 5 6 2 2 4 6 8 10 12 3 3 6 9 12 15 18 4 4 8 12 16 20 24 5 5 10 15 20 25 30 6 6 12 18 24 30 36 The program should produce a table of any size, specified by an integer input from a text box. (The structure of the input is irrelevant to this design.) 10.2 A data transmission from a remote computer consists of a series of messages. Each message consists of: 1. a header, which is any number of SYN bytes
- 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 152 and 153: Process header Process issue 10.4 M
- Page 154 and 155: 10.5 Structure clashes 131 As seen
- Page 156 and 157: 10.5 Structure clashes 133 Let us r
- 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 > > >
- Page 203 and 204: 180 Chapter 14 ■ The basics > Ear
- Page 205 and 206: 182 Chapter 14 ■ The basics > Cas
- Page 207 and 208: 184 Chapter 14 ■ The basics > > >
136 Chapter 10 ■ Data structure design<br />
Summary<br />
The basis of the data structure method is that the structure of a program can be<br />
derived from the structure of the files that the program uses. The method uses a diagrammatic<br />
notation <strong>for</strong> file and program structures. Using these diagrams, the method<br />
proceeds step by step from descriptions of the file structures to a pseudo-code design.<br />
The steps are:<br />
1. draw a diagram (a data structure diagram) describing the structure of each of<br />
the files that the program uses.<br />
2. derive a single program structure diagram from the set of data structure<br />
diagrams.<br />
3. write down the elementary operations that the program will have to carry out.<br />
4. associate the elementary operations with their appropriate positions in the program<br />
structure diagram<br />
5. trans<strong>for</strong>m the program structure diagram into pseudo-code.<br />
In some cases, a problem exhibits an incompatibility between the structures of<br />
two of its inputs or outputs. This is known as a structure clash. The method incorporates<br />
a scheme <strong>for</strong> dealing with structure clashes.<br />
•<br />
Exercises<br />
10.1 Design a program to display a multiplication table such as young children use. For<br />
example, the table <strong>for</strong> numbers up to 6 is:<br />
1 2 3 4 5 6<br />
1 1 2 3 4 5 6<br />
2 2 4 6 8 10 12<br />
3 3 6 9 12 15 18<br />
4 4 8 12 16 20 24<br />
5 5 10 15 20 25 30<br />
6 6 12 18 24 30 36<br />
The program should produce a table of any size, specified by an integer input from a<br />
text box. (The structure of the input is irrelevant to this design.)<br />
10.2 A data transmission from a remote computer consists of a series of messages. Each<br />
message consists of:<br />
1. a header, which is any number of SYN bytes