Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Software Engineering For Students: A Programming Approach Part 16. This fully revised version of Doug Bell's Software Engineering: A Programming Approach continues to use the successful formula of the previous editions. The author's approach is to present the main principles, techniques and tools used in software engineering, one by one, chapter by chapter. This book is a unique introduction to software engineering for all students of computer science and its related disciplines. It is also ideal for practitioners wishing to remain current with new developments in the area | 128 Chapter 10 Data structure design Figure 10.8 Data structure diagram for input file Report Total Figure 10.9 Data structure diagram for report Consider the following problem A serialfile describes issues and receipts of stock. Transactions are grouped into batches. A batch consists of transactions describing the same stock item. Each transaction describes either an issue or a receipt of stock. A batch starts with a header record and ends with a trailer record. Design a program to create a summary report showing the overall change in each item. Ignore headings new pages etc. in the report. The data structure diagrams are given in Figures 10.8 and 10.9. We now look for correspondences between the two diagrams. In our example the report as a whole corresponds to the input file as a whole . Each summary line in the report matches a batch in the input file. So we can draw a single composite program structure diagram as in Figure 10.10. 10.4 Multiple input and output streams 129 Process file produce report Process batch produce total Process Process Process header body trailer Process record Process Process issue receipt Figure 10.10 Program structure diagram for processing batches 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 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 .