What Do We Have So Far; Stepwise Refinement: An Example - IBM SC34-5764-01 Manual

Cics transaction server for vse/esa
Table of Contents

Advertisement

Programming Style and Techniques

What Do We Have So Far?

Putting all this together, we have:
/*------------------------------------------------------*/
/* Main program
/*------------------------------------------------------*/
do forever
call display
/*---------------------------------------------------*/
/* Mouse's turn
/*---------------------------------------------------*/
...
if mouse = hole then leave
if mouse = cat then leave
/*---------------------------------------------------*/
/* 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:
...
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.
94
CICS TS for VSE/ESA: REXX Guide
*/
*/
/* reaches hole */
/* hits cat
*/
*/
*/
*/
*/
*/
*/

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Rexx

Table of Contents