Step-wise refinement: an example
Your grandmother is going to knit you a warm woollen garment to wear
when
you go sailing. This is what she might do.
- Knit front
- Knit back
- Knit left arm
- Knit right arm
- Sew pieces together.
At this stage, look at the specification again. A sailor might
need to put on the pullover in the dark, quickly, without worrying
about the front or back. Therefore, the front should be the same as
the back; and the two sleeves should also be the same. This could
be programmed:
do 2
CALL Knit_body_panel
end
do 2
CALL Knit_sleeve
end
CALL sew_pieces_together
In programming, the best method is
to go on refining your program, working from the top, until you get
down to something that is easy to code.
Top down is the best approach.