Techniques of Structured Programming and Criticisms
Techniques of Structured Programming and Criticisms
on structured programming
1. Restrictions 139
2. Abstraction 141
3. Stepwise refinement 142
4. Notation 143
1. Pragmatics 150
2. Complexity 150
3. Rigidity 151
4. Methodology 155
4. Conclusion 157 ,
CHAPTER THREE
ON STRUCTURED PROGRAMMING
3.1. INTRODUCTION
One conclusion we can draw from the discussion in chapter two is that correct-
ness proving is by no means a trivial task, neither for sequential programs nor
for concurrent programs. The available analysis tools are not powerful enough
to allow for the verification of just any program. By necessity one must re-
strict oneself to simple and well-structured programs.
But, one may ask, what is a well-structured program?
Fortunately, there is a wealth of literature on this subject. The larger part
of this literature is primarily concerned with sequential programs, but still
we should take careful notice of these theories if we want to be able to apply
the underlying principles to the multiprocessing cases.
In this chapter we will study the techniques which have becOme known as 'struc-
ured programming' techniques. Before doing so we will dicuss the origination
of the theory and in that context we take a brief look at the so-called 'soft-
ware crisis' which stimulated this origination in many ways. We will also con-
sider how the structured programming methodology is related to more general
problem solving techniques. We will then survey the principal techniques from
structured programming, while concentrating ourselves on these four major as-
pects: restrictions, abstraction, stepwise refinement, and clear notation.
We conclude with a discussion of some of the major criticisms that have been
raised against the techniques.
It is not our intention to give, within the scope of a single chapter, a de-
tailed overview of all techniques that have been brought in connection with
structured programming theory. Such overviews can be found elsewhere (see, for
instance, Infotech '78). Our present goal is to describe and motivate the main
principles, in preparation of the studies in part 2 and 3 of this thesis.
The term 'structured programming' was coined by Dijkstra '69b. Though Dijkstra
is not the sole originator of the fundamental ideas behind structured program-
ming, he certainly was the first who succeeded in formulating his ideas on the
subject in a way which was understood and which initiated a wide discussion.
Without exaggerating, it can be said that Dijkstra created a new paradigm in
the computer sciences (Kuhn '62).
In retrospect, the occurrence of a 'paradigm shift' at that moment (i.e. the
late sixties) is easily understood. One was in the middle of the 'software
crisis'. Computers had become faster and bigger than anyone could have fore-
seen, and programmers were confronted with unmanageably large and complex soft-
ware. The construction of a reliable and understandable program of some size
had become an art, rather than a teachable skill. It was noted that the com-
plexity of a program grew almost exponentially with its size.
The negative effect of the use of certain language constructs on the under-
standability of a computer program had been debated on a small scale for some
134
years. Some initial thoughts on the subject can be found already in Dijkstra
'61 (especially pg. 4).
In Dijkstra '68a a reference is made to remarks of Zemanek in 1959.
Knuth '74 (pg. 264 and 265) refers to discussions with Schorre in 1963, to
an article of Naur in '63 and to papers of Landin and Naur presented at an
ACM Conference in 1966.
The discussion was however only really started after the publication of Dijk-
stra's provoking letter 'GO TO Considered Harmful'. The opening sentences of
that letter clearly illustrate its purport and style:
"For a number of years I have been familiar with the observation that
the quality of programmers is a decreasing function of the density
of GO TO statements in the programs they produce. More recently I
discovered why the use of the GO TO statement has such disastrous ef-
fects, and I became convinced that the GO TO statement should be
abolished from all 'higher level' programming languages (i.e. every-
thing except, perhaps, plain machine code)."
(Dijkstra '68a, pg. 147).
Phis letter unleashed a vast amount of articles, conference papers, and emotion-
al discussions. Another influential article of Dijkstra's was published a few
months later (Dijkstra '68b). In that paper Dijkstra illustrated how a large
complex software system could be designed and programmed in 'layers', by sys-
tematic abstraction. One year later, in 1969, the 'Notes on Structured Program-
ming' appeared as a report of the University of Technology in Eindhoven
(Dijkstra '69b). Despite the fact that these 'notes' were not distributed on a
wide scale, they had a large influence. In 1971 Wirth elucidated one of the
design techniques, 'stepwise refinement', to a wider audience (Wirth '71).
One year later, in 1972, Dijkstra's notes were re-published in book-form, sup-
plemented with papers by Hoare and Dahl (Dahl, Dijkstra & Hoare '72).
Two other important articles must be mentioned here. Both appeared in 1973.
The first one is the article by Wulf and Shaw titled 'Global Variables Consider-
ed Harmful' (Wulf & Shaw '73). (The titles of Dijkstra's articles have been
paraphrazed in many ways.) Wulf and Shaw argued that the use of variables with
a large scope can frustrate the analysis of a program. These ideas were later
elaborated by Dijkstra (Dijkstra '76, pg. 79-93).
The second article is the one from Nassi and Shneiderman who introduced a new
flow-charting technique for structured programs (Nassi & Shneiderman '73).
This technique, which was aptly named 'Structogramme' by Schnupp '74, derives
its value from the fact that it forces a programmer to think in terms of only
a few basic control-flow structures and prevents the (undisciplined) use of
GO TO statements.
We can summarize the principal ideas from the papers mentioned up to now in
these four concepts: restrictions, abstraction, stepwise refinement, and clear
notation. Each of these items was heavily debated. The ideas were extended,
modified and reduced, they were defended, ignored and attacked in large waves
of articles.
Of considerable influence upon the eventual acceptance of the ideas were the
many publications on the successful application of the techniques in large in-
dustrial programming projects. Already in 1973 there appeared an article en-
titled 'Revolution in P rogramming', from which we quote:
"Then came the IBM work for the New York Times, with reports of great-
ly increased programmer productivity and very greatly reduced coding
error rates (one detected error per 10.000 lines of coding, or one
per man year)! Absolutely incredible, but these were the facts."
(McCracken '73, pg. 51).
135
;idently, the reportings were often called in question. For instance, one
'ted that successes are published sooner than failures. Recently, a large soft-
.are institute wrote skeptically in a customer letter:
"- Many of the early successful projects were run by experienced or-
ganizations using top-level staff - how do the new techniques work
in practice in everyday installations?
- The very fact that an organization attempts to introduce new tech-
niques suggests a commitment to improving software production -
how much of the reported improvement is due to that commitment,
and how much to the new techniques?"
(Infotech, letter R377, Nov. 1978).
A more practical problem was that in many cases the programmers involved in the
industrial projects simply refused to alter their style of programming (see
Canning '74, pg. 3; Gries '74). The structured programming principles were
criticized both on practical grounds and for more philosophical reasons.
We take a closer look into the concrete criticisms in a later section (see sec-
tion 3.4). First we take a closer look into the nature of the 'software crisis'.
and on general problem solving techniques.
Within a few years Naur's prediction came true. In 1973 Donaldson already de-
scribed 'a major shift of emphasis' in software engineering.
"The primary requirement to be met in software engineering has always
been to perform the function specified for the software. But, where
at one time secondary emphasis was placed only on software efficien-
cy, that is in core and time required, today three other factors are
recognized as requiring special emphasis. These factors are reliabili-
ty, maintainability, and extensibility."
(Donaldson '73, pg. 52).
We can point out four major reasons for the occurrence of the change described
by Donaldson:
First of all, the machine is today no longer the most expensive 'link' in the
programming chain. Computer time has become relatively cheap. (See chapter 1,
section 1.1.)
Secondly, the considerable growth of computers and programs, both in size and
complexity, has made their reliability more and more important. Software sim-
plicity has become more important than hardware efficiency.
Thirdly, the average life time'of software has increased. Existing programs
must be adaptable to changing requirements, and not only by the people who ac-
tually wrote the programs in question. There are many ways to write a program
which no one understands (Kernighan & Plauger '74), butto write programs which
are transparent to any programmer is much more difficult. It requires another
attitude from programmers and a style of programming which Weinberg once de-
scribed as 'ego-less programming' (Weinberg '71).
The fourth reason concerns the multiprocessing systems. The advantage of a mul-
136
This does however not imply that the concerns for efficiency are to be entire-
ly neglected. Garren continued:
"By emphasizing ease of modification in system design and implemen-
tation it is possible to quickly build and debug the system and then
measure it to discover where optimization is actually needed."
"Local optimizations can contribute to a relatively small fractional
increase in program efficiency, whereas changes in global algorithm
can result in savings of orders of magnitude."
Concerns for program efficiency are thus merely moved to the final stages in
program design (see especially Knuth '74).
After the software crisis it became clear that the real bottle-neck in software-
development was not 'efficient coding' but structuredness, or 'efficient prob-
lem solving'. However, as Gries aptly remarked:
.. almost none of the elementary programming books say anything
about problem solving."
(Gries '74).
To design a program is to determine its structure. But, not just any structure
will make a program understandable. Especially, the . GO TO statement allows a
programmer to make highly complicated control-flow patterns.
Dijkstra suggested therefore that the programmer restrict himself mainly to
program structures which correspond closely to standard reasoning patterns.
When one deletes the GO TO statement, the programmer has only the following
'tools' for the construction of such patterns: concatenation, conditional se-
lection, iteration, procedure-calls, and recursion. Procedure-calls can (con-
ceptually) be replaced by the code they represent and they are therefore not a
fundamentally different type of tool. A recursion can be represented or under-
stood as an iteration, and it is therefore usually not considered separately
either. That leaves us with: concatenation, selection, and iteration. Liskov
writes:
"... each permissible control structure is associated with a well-
137
The ideas are not new (Knuth '74, pg. 291/292; Lecarme '74). It has even been
reported that some of the techniques had been in use for some time in 'arti-
ficial intelligence' projects (VandenBrug '74).
One of the more heavily debated questions with respect to the structured pro-
gramming methodology is whether programs should be designed 'top-down' or 'bot-
tom-up' (e.g. McClure '75). One of the early writers on problem solving, Polya,
says:
"We have before us an unsolved problem, an open question. We have to
find a connection between the data and the unknown.
We may represent our unsolved problem as an open space between the
data and the unknown, as a gap across which we have to construct a
bridge. We can start from either side, from the unknown or from the
data ..."
(Polya '48, pg. 73).
Polya did not express any principal preferences for either of these approaches,
and indeed it would be unwise to do so. In problem solving and in program de-
sign both analysis and synthesis play an important role. It has often be noted
that problem solving is essentially an iterative process. (See, for instance,
Davies '71, '76). It consists of repeated attempts to match the results of
analysis and synthesis. Similarly, the authors of the book 'Structured Program-
ming' (Dahl, Dijkstra & Hoare '72) explicitly stated in their preface that the:
.. structured programming principles can be equally applied in
'bottom-up' as in 'top-down' design."
'criticisms' (section 3.4). We will now give a survey of the principal struc-
tured programming techniques. We will do this under the headings: Restrictions,
Abstraction, Stepwise refinement, and Notation.
139
3.2.1. Restrictions
The most important restriction is that the programmer is asked to use only
three basic control-flow structures: concatenation, conditional selection and
iteration. These three basic structures are to be used as the 'building blocks'
of a program. They all have one entry-point and one exit-point, as illustrated
in figure 3.1 1 .
There have been many proposals for the inclusion of a special construct in the
'set of basic control-flow constructs' which would cover the error-exit and/or
the search-loop (e.g. Knuth & Floyd '71; Friedman '74; Evans '74; Goodenough
'75). There is, however, no consensus on this point. More liberal authors have
suggested not eliminating the goto statements, but restricting their usage.
Three alternatives are then:
Wulf and Shaw suggested restricting the scope of variables, and requiring that
this scope is always made explicit in a program text via declarations. The rea-
sons for these further restrictions are:
.. the non-local variable is a major contributing factor in pro-
grams which are difficult to understand."
.. the complexity of [the task to prove that variables are always
accessed in the intended way] increases exponentially with the
distance of the last previous use of each variable along each con-
trol path."
.. the complexity of the abstraction is directly related to the
number of non-local variables used."
(Wulf & Shaw '73, pg. 28/29).
Wulf and Shaw further argued that an access right to a variable which has been
declared on a high level in a nesting hierarchy should not be 'inherited'
(exported) automatically by (to) all lower levels . Upon entry to a new level
(a 'block') all variable declarations that are to be 'inherited' (imported)
must then declared be explicitly. Dijkstra elaborated similar ideas in
Dijkstra '76.
An inherited (imported) variable is called 'global' by Dijkstra, a new vari-
able is called 'local'. The scope of a local variable extends from the begin-
141
ning to thp end of the block in which it is declared, with the exception of
those inner blocks that do not explicitly inherit it via a 'global' declaration
(Dijkstra '76, pg. 85). All variables must be initialized before their first
use. A non-initialized variable is called a 'virgin' variable. Via the declara-
tions one can declare whether the variables will be used as references (con-
stants) or will be changed in the corresponding block. Dijkstra then defines 6
different types of variables which can occur in a block (local, global or vir-
gin variables, used as constants or as 'true' variables) with special 'rules of
inheritance'. (Dijkstra '76, pg. 91).
As a possible extension of these ideas both Dijkstra and Wulf & Shaw have men-
tioned the possibility of making explicit and restricting also the ways in
which variables can be modified.
Another type of additional restriction was suggested by Bloom '75 and Weinberg
at al. '75. They suggested eliminating the 'conditional selection' construct,
and replacing it by a 'conditional execution (i.e. replacing the 'if-then-else-
end' by 'if-then-end'). This suggestion has not found much support, and indeed
it seems that it would be too restrictive. It would make program structures
more simple, but it can be questioned whether it would make them more under-
standable.
An article which is often quoted in discussions on structured programming tech-
niques is Bohm & Jacopini '66.
Bohm & Jacopini '66 showed that every flow diagram with goto-statements can be
transformed in a goto-less one. (See also Mills '72 who presented a more rigor-
ous proof of their statements. See also Ashcroft & Manna '71.) The programs are
then equipped with some additional state variables' which formalize part of the
flow-of-control. It will be obvious, however, that such transformations have
no relevance to structured programming whatsoever. Dijkstra stated:
"The exercise to translate an arbitrary flow diagram more or less
mechanically into a jumpless one, however, is not to be recommend-
ed. Then the resulting flow diagram cannot be expected to be more
transparent than the original."
(Dijkstra '68a, pg. 148).
The same point was also clearly illustrated by Cooper who demonstrated, in a
reaction to Bohm & Jacopini's paper, that any flow diagram can trivially be
transformed into a single iteration loop containing one large case-selection
structure. The resulting program is 'simple' indeed, but certainly not under-
standable (Cooper '66).
3.2.2. Abstraction
In the initial stages of program designing the main problem is to find the ma-
jor lines of the solution. Abstraction (or 'generalization' as Polya called it)
is a powerful mental aid to discover what is detail and what is not.
"Executional abstraction is so basic to the whole notion of 'an al-
gorithm' that it is usually taken for granted and left unmentioned.
(-) ... it refers to the way in which we can get a specific compu-
tation within our intellectual grip by considering it as a member
of a large class of different computations ..."
(Dijkstra '76, pg. 1).
my program."
(Dijkstra, in: Dahl, Dijkstra & Hoare '72, pg. 27).
where the mistake was made and continues with a different approach. The design
process is thus essentially an iterative process, though in its idealized form
one is tempted to define it as a one-pass procedure.
Together with the refinement of the program one refines the structure of the
data. Decisions about the implementation of high level data structures are
postponed for as long as can be.
The high level, or pseudo-code (the latter term is from Melekian '76) can be
regarded as a form of 'structured comment' to the code of the leVels immediate-
ly below it in the design hierarchy. The design process naturally stops when
then lowest level has been reached, that is a description in the code of the
programming language used. Gries, therefore, aptly remarked that with struc-
tured programming:
"... one doesn't program in a programming language but into it."
(Gries '74, pg. 656).
3.2.4. Notation
We discuss four items which are related to a clear notation of problems and
solutions: data representations, flow-charts, documentation, and programming
languages.
Data representations
Many articles have been published on the question of what type of data repre-
sentation would lend itself best to the structured programming techniques (for
instance, Hoare, in; Dahl, Dijkstra & Hoare '72; Shneiderman & Scheuerman '74;
see also Jackson '75).
Two important articles have not gained the attention they deserve. One of them
was published just before the wide discussions on programming style began
(1967), the other a few years later (1971). We consider these two articles
briefly below.
The first article is Balzer '67. Balzer proposed to keep the data manipulations
in the design phase independent of specific data representations. The program-
mer then uses informal operations in his program text, like 'delete record', or
'replace', leaving the refinements to a later stage in program design. The meth-
od fits well in the stepwise refinement procedures outlined earlier. We quote:
... programming should be simplified because it can be constructed
top-down in terms of the logical processing required. The problem
144
The second article is by Eaily '71. Early described the 'V-graph model' for
data representations. These V-graphs represent the set of data on an arbitrary
level of abstraction, and not (necessarily) the way in which the data is im-
plemented (Early '71, pg. 618).
An example of a V-graph is given in figure 3.3. Early explained the meaning as
follows:
"Each node of the graph represents a part of the data structure.
The arrows between nodes represent access paths in the structure,
and arrows from nodes to 'atoms' represent the fact that the atom
is stored at the node."
"NIL is a reserved object which can be used for such things as the
end of a list."
10
Figure 3.3.
EarZy's V-graph model
The annotations on the edges of the graph indicate subscript variables (or
'selectors' as Early calls them). In the example of figure 3.3 the elements
10, 20 and 30 can be accessed by subscripts as well as via the standard opera-
tion NEXT. The names NEXT and CONT are not reserved words though; one can use
any other suitable notation (PRIOR, FOLLOW, ADJACENT, IMAGPART, REALPART, AGE,
YEAR, etc.).
Flow charts
-
In 1973 Nassi & Shneiderman suggested quite another approach to the problem,
and their attempt was more successful. Nassi & Shneiderman introduced a new
type of flow-chart which removes all objections mentioned, to a large extent.
In addition, they noted that:
146
The three basic control-flow-structures are represented in the new model as in-
dicated in figure 3.5. The representation of a block or hierarchical level is
indicated in figure 3.6. The representation of a recursive subroutine is illus-
trated in figure 3.7.
A a
(a) (b)
Concatenation Selection
DOWHILE
Figure 3.5.
Structogramme
Notations
(c) (d)
Case Selection Iteration
A:
a
A
Unfortunately, the resemblence with a Boolean algebra is not valid for the ma-
nipulations of the 'formula's'. For instance, it can be shown that the struc-
ture which corresponds to the formula: (a+ fib) .c is equivalent to the struc-
ture corresponding to the formula: (a.c+p.c) . In other words: it can be shown
that the dot-operation is 'right-distributive' over the +. To show that the
structure given in figure 3.8.a is equivalent to that of figure 3.8.b, or that
the relation:
R1 (R2.a+J1).b.(1+ 2) R2.111 (Si+ .b. (a+ „J2)
Pj a
holds, is however much more complicated.
The approach suggested by Pazel deserves more attention then can be paid to it
in the present context. We leave this as a recommendation for further research.
Documentation
We have noted that the abstract solutions which are drafted in the process of
stepwise refinement can serve as structured comments to the derived program.
Linger & Mills have suggested using still more stringent rules for the inclu-
sion of comments in a program text. They have stated that all data structures
and all actions taken in a program should be explained explicitly in the form
of comments to the code.
In general, every data object introduced should have a data defini-
tion giving its contextual meaning. An action definition should
precede the program part it refers to, and a status definition should
follow the program part which produced the status."
(Linger & Mills '75, pg. 179).
Linger & Mills further suggested preceding each iteration loop with a specifi-
cation of the corresponding loop-invariant assertion.
ments which appear in the program text itself are then the 'chapter headings'
etc. Similar proposals were published by Berry '75.
One other important method of making a program text more understandable is the
hierarchical indentation of that text. Clearly, this indentation is merely an
additional tool to make structured programs understandable. It will, however,
not make a poor design much stronger. An amusing example of this was given by
Van Amstel '77. Van Amstel quoted a person who had the impression that struc-
tured programming boiled down to requiring that sentences like:
'The one who denounces the one who pulled down the pole that stood
near the bridge in the road that leads to Worms which was recently
opened over the canal of ten feet tall within ten days will be re-
warded.'
should,be written as follows:
'The one
who denounces the one
who pulled down the pole
that stood near the bridge
in the road
that leads to Worms
which was recently opened
over the canal
of ten feet tall
within ten days
will be rewarded.'
Programming languages
The question of whether the existing programming languages are suited to struc-
tured programming practice has been raised repeatedly. Already in 1962 McCarthy
wrote:
"At present, programming languages are constructed in a very unsys-
tematic way. (-) A better understanding of the structure of compu-
tations and of data spaces will make it easier to see what features
are really desirable."
(McCarthy '62).
More than once the language FORTRAN has been criticized for its lack of struc-
ture, and the omnipresence of goto-jumps. But, FORTRAN is not really an excep-
tion: in fact no language seems to meet the standards completely.
Lecarme posed the rhetorical question to his readers:
"Is it possible to write structured programs (-) in any language?"
The subject was discussed among others by Wulf at aZ. '71; Peck '72; Clark at
al. '73; Wirth '74, and in Update, Vol. 2, No. 5, pg. 8-10, May 1977.
In Lecarme '72 the following requirement was formulated:
"... conciseness, structure and clarity (-) are probably the most
important qualities of any program. We intentionally omit efficien-
cy, because we believe that a program that is concise, structured
and clear must be efficient otherwise the programming language is
bad."
The programming languages which seem to answer this requirement best include
ALGOL-68, ALGOL-W, and PASCAL.
150
3.3. DISCUSSION
More fundamental objections have however been raised against the methodology,
which we will consider here. The criticisms can be divided into four topics:
• pragmatics,
• complexity,
• rigidity, and
• methodology.
3.3.1. Pragmatics
3.3.2. Complexity
Another criticism is that the structured design techniques are in fact just as
•complicated as the traditional methods (Abrahams '75). To choose the right data
representation, the right program structure, is still far from trivial.
It is then argued that 'poor programmers' will still write 'poor programs' even
if they apply the structured programming techniques. This criticism can however
be refuted. Structured programming cannot pretend to be a 'magic wand' which
alters 'poor programmers' into first-class programmers. It does, however, offer
the instruments for good program design. As always these instruments can be
used correctly and incorrectly. Denning explained:
"The understandability of the product remains basically a matter of
style: some programmers have good style, others do not. Good program-
ming style is not automatically introduced by the rules of struc-
tured programming, any more than good English prose style is guaran-
teed by following the ten famous rules listed in Strunk & White's:
The Elements of Style ... though these rules can go a long way to-
ward influencing programmers or writers in the direction of good
style, ..."
(Denning '74, pg. 6).
151
3.3.3. Rigidity
Many authors have 'complained' that the rules of structured programming are too
strict. Some say that their strict application can lead to inferior programs.
Some even claim that their strict application is impossible.
Abrahams, for instance, questions whether each program can be given a 'tree-
structure' (hierarchical structure), whether global variables can always be
avoided in large programs, and whether goto-jumps can always be avoided. Johnson
stated much earlier:
"In some cases, it is difficult or impossible to write a program
without crossing one branch line by another."
(Johnson '70, pg. 122).
(1) the iteration construct is sometimes too strong, for instance, for program
segments that must be repeated just once;
(2) overlapping iteration structures can be of value, but are forbidden;
(3) there is a need for the representation of 'error-exits'.
The need for a clear notation of 'error-exits' has been stressed repeatedly,
and as such it would of course not contradict the goals of structured program-
ming to include such a special construct in a language. The flow-of-control in
a program should however be prevented from being diffused by such special con-
structs. One obvious requirement is then that it should not be possible to
'jump' from the error-routines back into the program at some intermediate point.
Another item in what has been called the 'goto-controversy' is the use of loop-
exit structures. The classic example is the 'search-loop'. A search-loop has
two or more possible outcomes: the search is successful (in one or more ways)
or it is not. Each outcome may require a different response. Without special
constructs for the programming of such loop-exit structures one is tempted to
use goto-statements instead.
The represenation of the loop-exit structures is greatly facilitated if one
decouples the declaration of iteration conditions and loop-structures.
In the traditional loop constructs WHILE(...)D0 ... OD and REPEAT ... UNTIL(..)
the iteration condition must be evaluated either at the start or at the end of
the loop-body; they can however not be evaluated within the loop-body.
An alternative construct, much in line with the proposals of e.g. Knuth & Floyd
'71, and Wirth '67 (pg. 29) would be to use the key-word REPEAT in combination
with the exit-statements EXITIF(condition; DOING: statements). The exit should
then be from the innermost block or loop. With a still more liberal approach
we could allow for exits from any level in the nesting hierarchy. The level to
be exited must then be specified: EXITIF(condition; FROM: level; DOING : state-
ments).
In figure 3.9 we have given a complex non-decomposable flow-chart discussed by
Peterson et al. '74. In figure 3.10 the description of that flow-chart in a
structogramme, extended with EXITIF statements, is given. The structogramme was
obtained by a redrawing of the flow-chart into the more structured one of
figure 3.11 in which a few blocks of code have been duplicated. For comparison
we reproduce the notation of the same flow-chart with the aid of a WHILE-UNTIL
construct (without code-duplications), taken from Friedman & Shapiro '74 (pg.
11), below.
The difference in clarity of the control flow in the programs need hardly be
stressed.
S
a1 a2
b1
C l C2
d2 d1
Figure 3.0.
Non-Decomnoeable Flow Chart
153
REPEAT (I)
REPEAT (:1)
EXITIF(A El)
a2
EXITIF( i:):I; DOING:d2)
(Lb di
a 1
REPEAT ( ilL)
EXITIF( C: TTT)
c2
EXITIF(T3- :I; DOING: b2)
hi
IP.
CI
EXITIF(D:I; DOING: d2 )
di
(I)
Figure 3.10.
Structogramme With REPEAT/EXITIF Construct
154
ID,
Figure 3.11.
Redrawn Flowchart for Fig. 3.9.
(with some code-duplications)
155
S; while (if A
then (if (while true repeat al until true)
then (if (while B repeat bi until
(if C then true
else not(while true repeat c2 until true)))
then (while true repeat ci until true)
else not(while true repeat b 2 until true))
else false)
else (while true repeat a 2 until true))
repeat until (if D then not(while true repeat d1 until true)
else (while true repeat d2 until true)); T
3.3.4. Methodology
The conflict described by Naur is however only apparent. The first precept Naur
gives resembles Polya's advice to 'discover the major lines of the argument'
and the rule of abstraction from structured programming.
The second precept is completely in agreement with the design rule of stepwise
refinement, and confirms Polya's remark:
"... it is not reasonable to check minor details before we have good
reasons to believe that the major steps of the argument are sound."
(Polya '48, pg. 69).
Every programmer knows from his own experience that the task of designing pro-
gram, or the task of solving a problem, is hardly ever executed as a pure top-
down process. Denning (citing Wilkes) made the following illustrative compari-
son:
"[compare] writing a textbook to writing a program: (-) the process
of creating, and of evolving, that structure can hardly be charac-
156
That program designing or problem solving is no pure top-down process does how-
ever not imply that it lacks all structure. Oddly enough Polya gives his read-
ers that impression when he gives the following, playful description of the
'rules of discovery':
"The first rule of discovery is to have brains and good luck.
The second rule of discovery is to sit tight and wait till you get
a bright idea."
(Polya '48, pg. 172).
Some problems are however so inherently complex that indeed no method other
than the ones described,here - by Polya may be of use. One such a problem is the
problem of the 'Tower of Hanoi'. Peck '72 made a comparison of the abilities of
a number of programming languages to give a clear representation of the program
which solves this problem. None of the examples is very understandable though.
These observations do, however, not really undermine the applicability of the
structured programming techniques, especially because there are no alternative
techniques which have proved to be more powerful.
157
3.4. CONCLUSION
3.5. REFERENCES
Ashcroft, E. & Manna, Z. (1971), The translation of 'goto' programs into 'while'
programs, Computer Science Dept., Report CS-188, Stanford University, also
presented at IFIP '71, Jan. 1971.
Baker, F.T. (1975), The pros and cons of structured programming, Data Manage-
ment, Vol. 13, No. 9, pp. 60-71, Sept. 1975.
Balzer, R.M. (1967), Dataless programming, Proc. AFIPS 1967 FJCC, AFIPS Press,
Montvale (N.J.), pp. 535-544, 1967.
Berry, D.M. (1975), Structured documentation, Sigplan Notices, Vol. 10, No. 11,
pp. 7-12, Nov. 1975.
Berzheim, H. (1975), Fernwirkungsfreie, strukturierte Programmierung, Online,
Vol. 13, No.. 4, pp. 234,, 237-240, 1975.
Bloom, A.M. (1975), The 'else' must go, too, Datamation (U.S.A.), Vol. 21, No.
5, pp. 123-128.
Bohm, C. & Jacopini, G. (1966), Flow diagrams, Turing machines and languages
with only two formation rules, Comm. ACM, Vol. 9, No. 5, pp. 366-371, May
1966.
Bulow, K. (1974), Programming in book format, Datamation, Vol. 20, No. 10, Oct.
1974.
Canning, R.G. (ed.) (1974), The advent of structured programming, EDP Analyzer
(U.S.A.), Vol. 12, No. 6, pp. 1-14, June 1974.
Clark, B.L. et al. (1973), Reflections on a language design to write an oper-
ating system, Sigplan Notices, Vol. 8, No. 9, 1973.
Cooper, D.C. (1967), Bohm and Jacopini's reduction of flow charts, Comm. ACM,
Vol. 10, No. 8, pp. 463, 1967.
Dahl, 0.J., Dijkstra, E.W. &.Hoare, C.A.R. (1972), Structured programming,
Academic Press, London, 1972, 220 pgs.
Davies, I.K. (1971), The management of learning, McGraw-Hill, London, 1971.
Davies, I.K. (1976), Objectives in curriculum design, McGraw-Hill, London, 1976.
Denning, P.J. (1974a), Is it not time to define structured programming?, Oper-
ating Systems Review, Vol. 8, No. 1, pp. 6 7, Jan. 1974.
-
Denning, P.J. (1974b), Is structured programming any longer the right term?,
Operating Systems Review, Vol. 8, No. 4, pp. 4-6, April 1974.
Dennis, J.B. (1975), Modularity, Lect. Notes in Computer Science, Vol. 30, pp.
128-182, Springer Verlag, 1975.
Donaldson, J.R. (1973), Structured programming, Datamation, Vol. 19, No. 12,
pp. 52-54, 1973.
Dijkstra, E.W. (1961), On the design of machine independent programming lan-
guages, Report MR34-Math. Centre, Amsterdam, Oct. 1961, 18 pgs.
Dijkstra, E.W. (1968a), GO TO statement considered harmful, Comm. ACM, Vol. 11,
No. 3, pp. 147-148, 538, 541, March 1968.
Dijkstra, E.W. (1968b), The structure of the 'THE' multiprogramming system,
Comm. ACM, Vol. 11, No. 5, pp. 341 346, May 1968.
-
Evans, R.V. (1974), Multiple exits from loops using neither goto nor labels,
comm. ACM, Vol. 17, No. 11, pg. 650, Nov. 1974.
Flon, L. (1975), On research in structured programming, Sigplan Notices, Vol.
10, No. 10, pp. 16-17, 1975.
Friedman, D.P. & Shapiro, S.C. (1974), A case for Sigplan
Notices, Vol. 9, No. 7, pp. 7-14, July 1974.
Garren, S. (1973), Structured programming, DECUS Fall 1973, Symposium, San
Fransisco, Cal., U.S.A., Nov. 1973, pp. 37-39.
Goodenough, J.B. (1975), Structured exception handling, In: Conference Record
of the 2nd ACM Symposium on the 'Principles of programming languages', pp.
204 224, Jan. 1975.
-
Linger, R.C. & Mills, H.D. (1975), Definitional text in structured programming,
Proc. of the 14th Annual Technical Symposium on: 'Computing. in the mid
70's: and assesment', Gaithersburg (Md.), June 1975. Reprinted in: Proc.
IEEE Compcon '75, Tutorial on Structured, rogramming, pp. 178 183. .
-
Liskov, B.H. (1972), A design methodology for reliable software systems, Proc.
of the 1972 FJCC, AFIPS Press, Montvale (N.J.), pp. 191 199, 1972.
-
McClure, C.L. (1975), Top down, bottom up, and structured programming, IEEE
- -
Trans. on Software Eng., Vol. SE 1, No. 4, pp. 397 403, Dec. 1975.
- -
Nassi, J. & Shneiderman, B. (1973), Flow chart techniques for structured pro-
gramming, Sigplan Notices, Vol. 8, No. 8, pp. 12 26, 1973.
-
Weinberg, G.M. (1971), The psychology of computer programming, New York, Van
Nostrand Reinhold Co., 1971.
Weinberg, G.M., Geller, D.P. & Plum, T.W.S. (1975), 'If then else' considered
- -
harmful, Sigplan Notices, Vol. 10, No. 8, pp. 34-44, August 1975.
Wirth, N. (1967), On certain basic concepts of programming languages, Report
Stanford Univ.,Comp. Sc. Dept., May 1967, 30 pgs.
Wirth, N. (1971), Program development by stepwise refinement, Comm. ACM, Vol.
14, No. 4, pp. 221 227, April 1971.
-