TAILIEUCHUNG - Software Engineering For Students: A Programming Approach Part 12

Software Engineering For Students: A Programming Approach Part 12. 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 | 88 Chapter 7 Structured programming Figure The three structures of structured programming One view of structured programming is that it holds that programs should only be built from three components sequences normally written in the order in which the statements are to be executed selections normally written as if-then-else and repetitions written as while-do . The goto statement is by implication banned. In this chapter we begin by examining the controversy about the goto statement. The outcome of the argument is that gotos are an irrelevancy the argument is about something else good program structure. We go on to explore the significant principles of structured programming. There are some other principles. We will explore these using flowcharts which describe flow of control. A flowchart is read from the top downwards or in the direction of the arrows. Flowchart decisions corresponding to if or while statements in code are drawn as diamonds. Flowchart activities are shown as rectangular boxes. A flowchart is very similar to a UML activity diagram and conveys the same information. If the three structures of structured programming are diagrammed as flowcharts Figure the following characteristics become clear 1. they have only one entry and exit 2. none of the constructs consists of more than three boxes Figure A control structure that is not structured Arguments against goto 89 If we visualize any one of the three constructs as they are used then a third characteristic is evident 3. the entry is at the start and the exit is at the end. Why is it that these characteristics are important Why are other constructs that have the same characteristics Figure ruled out We now go on to look at these questions. SELF-TEST QUESTION Write a loop that repeats ten times first using a while statement then using goto. Arguments against goto gotos are unnecessary Fortunately there is a mathematical theorem thanks to Bohm and Jacopini guaranteeing that any