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.
Let's play a game! Type "Heads", "Tails",
or "Quit"
and press ENTER.
This means that there are four possible
inputs:
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.