There are many choices for what the implementation can be:
2. The implementation can be a single statement (e.g. an assignment state-
ment or a conditional statement), a sequence of statements (some in
English and some in the programming language), and so forth.
There is a choice of notation to use:
3. We prefer to use a mixture of English and Java, moving closer and clos-
er to Java at each step, so that the final result is a Java program.
To this end:
4. We make heavy use of statement-comments.
5. We introduce methods and method calls in appropriate places, to keep the
program appearance simple.
It is important to realize that:
6. At each step, the program that has been written so far is correct. However,
some of the methods are not completely in Java. They contain English
One point that we have not discussed yet is the introduction of variables:
7. If a step of a top-down design introduces variables, this may cause
changes in several statements that have to refer to those variables. When
variables are introduced, it is important to write program comments that
describe the meanings of the variables.
Top-down design in other fields
We often think that what we are doing is new and exciting and all ours. This
is true also of top-down design when it was first discussed in programming in the
very early 1970s. However, top-down design is used in almost all fields, since it
is about the most logical way one can think of to develop anything. In fact, even
people in poetry have used it. Edgar Allen Poe, for example, wrote an essay on
how he developed the poem The Raven . He did not use the term top-down
design, but he sure used the concept! We urge you to put the ProgramLive CD in
your computer and watch a discussion of his essay.
You have to
see it. You can
get the essay
and the poem
Top-down development of a Java task
We look at stepwise refinement in a real programming situation. In this devel-
opment, we emphasize that we are not only doing stepwise refinement, we are
also using incremental programming and incremental testing. At every step, we
compile the program to make sure that it is syntactically correct and then do
whatever testing we can. This is far better than writing the whole program and
does this better,
using time and
tion. Watch it!