Software Engineering for Students A Programming Approach

Software Engineering for Students A Programming Approach Software Engineering for Students A Programming Approach

web.firat.edu.tr
from web.firat.edu.tr More from this publisher
21.08.2013 Views

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

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

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

Saved successfully!

Ooh no, something went wrong!