Structured Programming
Structured Programming
1
Bad Programming Habits
Undesirable Results !
Do not know how to program
Programs with numerous bugs that take extremely long
time to debug, or even failure to complete
Any change of requirement invites rewriting of the entire
program again
2
Benefits of Structured Programming
3
Structured Programming
5
2. Stepwise Refinement
A “DIVIDE and CONQUER” strategy
When given a large job, divide it into smaller jobs.
Given any job, it is useful to divide it into
Input
Process
Output
Draw a tree
Refine each job level by level (Breadth first)
Use pseudo code to describe each job
Decision on data structure is delayed as much as
possible
6
Extremely
Complex
Job
… …
Input from
user Initialize Level 2
…
Initialize security Level 3
settings
7
3. Modular Design
8
4. Bottom Up Coding
10
6. White Box and Black Box Testing
White Box
Input something for which you know the desired
result, it should give your expected output
Black Box
Treat it as a black box, input some data, is the
result reasonable?
11
7. Structured Programming Documents
13
References
General Philosophy
Numerous books about Structured Programming in the
library
A very good structured programming example
W. Findlay and D.A. Watt, Pascal: An Introduction to
Methodical Programming 1987, Ch. 7 illustrates how to use
stepwise refinement to program a complicated task. Try it
YOURSELF once, then you would get it
14