IBM SC34-5764-01 Server User Manual


 
What Do We Have So Far?
Putting all this together, we have:
The method that we have just discussed is sometimes called stepwise refinement. You start with a
specification (which may be incomplete). Then you divide the proposed program into routines, such that
each routine will be easier to code than the program as a whole. Then you repeat the process for each of
these routines until you reach routines that you are sure you can code correctly at the first attempt.
While you are doing this, keep asking yourself two questions:
v What data does this routine handle?
v Is the specification complete?
Stepwise Refinement: An Example
Granny is going to knit you a warm woolen garment to wear when you go sailing. This is what she might
do.
1. Knit front
2. Knit back
3. Knit left arm
4. Knit right arm
5. Sew pieces together.
Each of these jobs is simpler to describe than the job of knitting a pullover. In computer jargon, breaking a
job down into simpler jobs is called stepwise refinement.
/*------------------------------------------------------*/
/* Main program */
/*------------------------------------------------------*/
do forever
call display
/*---------------------------------------------------*/
/* Mouse's turn */
/*---------------------------------------------------*/
...
if mouse = hole then leave /* reaches hole */
if mouse = cat then leave /* hits cat */
/*---------------------------------------------------*/
/* Cat's turn */
/*---------------------------------------------------*/
...
if cat = mouse then leave
end
/*------------------------------------------------------*/
/* Conclusion */
/*------------------------------------------------------*/
call display
if cat = mouse then say "Cat wins"
else say "Mouse wins"
exit
/*------------------------------------------------------*/
/* Subroutine to display the state of play */
/* */
/* Input: CAT and MOUSE */
/* */
/*------------------------------------------------------*/
display:
...
Programming Style and Techniques
94
CICS TS for VSE/ESA: REXX Guide