|
Table of Contents
Learning C++:
An Index of Entry Points
2. The A reference document on the basic elements of C++.
3. The Patterns
|
A. Patterns and Purpose Statements As part of the analysis phase for a problem, you discover the purpose
of a program. Notice that the various patterns also have a purpose. The
average pattern, for example, has as its purpose:
Big deal, hu? But, if you compare the purpose of your problem with the
purpose of the various patterns you might find a match! If you decide, for
example, that the problem you have in front of you needs an average
calculated, it is clearly time to pull out the old average pattern. Please take advantage of these patterns. If you don't, you will be
're-inventing the wheel' every time you start a new program. To summarize
then - the steps you know for successfully completing a programming
problem are: Each of these steps depends on the ones above it and, if you discover a
problem, you may need to go back to an earlier step to fix that problem.
When you think you are finished, make sure that the output you have
matches your specifications. It is not uncommon for programmers to write a
set of specifications and then drift away from them as they go through the
rest of the steps. It is a bit like that game where one person whispers
something into someone's ear and the 'secret' gets passed from person to
person, and finally passed back to the original person. Usually, the final
version of the secret is quite different from the original. And, be careful with your testing. For example, in the average problem
we just looked at, a good set of tests would have included two or three
sets of numbers whose averages were easily calculated. Three test
possibilities might be:
In general if your program has multiple 'paths' (different sets of code
that are chosen by 'if' and 'while' test conditions) each of those paths
should be tested with a data set. B. Wrap Up |