
Chapter 10. Programming Style and Techniques
The
method
you use for constructing your programs is just as important as the
language
you use to write
them.
Consider the Data
When you are faced with the task of writing a program, the first thing to consider is the data you are
required to process. Make a list of the input data—what are the items and what are the possible values of
each? If the items have a kind of structure or pattern, draw a diagram to illustrate it. Then do the same for
the output data. Study your two diagrams and try to see if they fit together. If they do, you are well on the
way to designing your program.
Next, write the specification that the user will use. This might be a written specification, a HELP file or
both.
Last of all, write your program.
Here is a little example:
You are required to write an interactive program that invites the user to play “Heads or tails”. The game
can be played as long as the user likes. To end the game the user should reply
Quit
in answer to the
question “Heads or tails?” The program is arranged so that the computer
always
wins.
Think about how you would write this program.
The computer starts off with:
Let's play a game!
Type "Heads", "Tails",
or "Quit"
and press ENTER.
This means that there are
four
possible inputs:
v
HEADS
v
TAILS
v
QUIT
v
None of these three.
And so the corresponding outputs should be:
v
Sorry. It was TAILS. Hard luck!
v
Sorry. It was HEADS. Hard luck!
v
That's not a valid answer. Try again!
And this sequence must be repeated indefinitely, ending with the return to CICS.
Now that you understand the specification, the input data and the output data, you are ready to write the
program.
If you had started off by writing down some instructions without considering the data, it would have taken
you longer.
Test Yourself...
Write the program. If you are careful, it should run the first time!
© Copyright IBM Corp. 1992, 2009
89
Summary of Contents for SC34-5764-01
Page 1: ...CICS Transaction Server for VSE ESA REXX Guide SC34 5764 01...
Page 2: ......
Page 3: ...CICS Transaction Server for VSE ESA REXX Guide SC34 5764 01...
Page 22: ...xx CICS TS for VSE ESA REXX Guide...
Page 23: ...Part 1 User s Guide Copyright IBM Corp 1992 2009 1...
Page 24: ...2 CICS TS for VSE ESA REXX Guide...
Page 40: ...18 CICS TS for VSE ESA REXX Guide...
Page 54: ...Using Variables and Expressions 32 CICS TS for VSE ESA REXX Guide...
Page 106: ...84 CICS TS for VSE ESA REXX Guide...
Page 110: ...88 CICS TS for VSE ESA REXX Guide...
Page 122: ...100 CICS TS for VSE ESA REXX Guide...
Page 123: ...Part 2 Reference Copyright IBM Corp 1992 2009 101...
Page 124: ...102 CICS TS for VSE ESA REXX Guide...
Page 130: ...Introduction 108 CICS TS for VSE ESA REXX Guide...
Page 152: ...REXX General Concepts 130 CICS TS for VSE ESA REXX Guide...
Page 224: ...Functions 202 CICS TS for VSE ESA REXX Guide...
Page 252: ...230 CICS TS for VSE ESA REXX Guide...
Page 278: ...256 CICS TS for VSE ESA REXX Guide...
Page 312: ...DB2 Interface 290 CICS TS for VSE ESA REXX Guide...
Page 316: ...High level Client Server Support 294 CICS TS for VSE ESA REXX Guide...
Page 340: ...318 CICS TS for VSE ESA REXX Guide...
Page 344: ...for execs Commands 322 CICS TS for VSE ESA REXX Guide...
Page 399: ...Part 3 Appendixes Copyright IBM Corp 1992 2009 377...
Page 400: ...378 CICS TS for VSE ESA REXX Guide...
Page 438: ...416 CICS TS for VSE ESA REXX Guide...
Page 442: ...System Definition Customization Administration 420 CICS TS for VSE ESA REXX Guide...
Page 446: ...Security 424 CICS TS for VSE ESA REXX Guide...
Page 448: ...426 CICS TS for VSE ESA REXX Guide...
Page 464: ...442 CICS TS for VSE ESA REXX Guide...
Page 466: ...444 CICS TS for VSE ESA REXX Guide...
Page 468: ...446 CICS TS for VSE ESA REXX Guide...
Page 476: ...454 CICS TS for VSE ESA REXX Guide...
Page 478: ...456 CICS TS for VSE ESA REXX Guide...
Page 479: ......
Page 480: ...SC34 5764 01...
Page 481: ...Spine information CICS TS for VSE ESA REXX Guide...