< previous page page_154 next page >

Page 154
width for printing one of the values. Calculating fieldwidths is not the purpose of the program. If you shift your focus to the calculation, you are more likely to forget some detail of the overall printing process. What you do is write down an abstract step''Calculate the fieldwidth required"and go on with the problem at hand. Once you've completed the general solution, you can go back to solving the step that does the calculation.
By subdividing the problem, you create a hierarchical structure called a tree structure. Each level of the tree is a complete solution to the problem that is less abstract (more detailed) than the level above it. Figure 4-4 shows a generic solution tree for a problem. Steps that are shaded have enough implementation details to be translated directly into C++ statements. These are concrete steps. Those that are not shaded are abstract steps; they reappear as subproblems in the next level down. Each box in the figure represents a module. Modules are the basic building blocks in a top-down design. The diagram in Figure 4-4 is also called a module structure chart.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif 3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Concrete Step A step for which the implementation details are fully specified.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif 3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Abstract Step A step for which some implementation details remain unspecified.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif 3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Module A self-contained collection of steps that solves a problem or subproblem; can contain both concrete and abstract steps.
Modules
A module begins life as an abstract step in the next higher level of the solution tree. It is completed when it solves a given subproblemthat is, when it specifies a series of steps that does the same thing as the higher-level abstract step. At this stage, a module is functionally equivalent to the abstract step. (Don't confuse our use of function with C++ functions. Here we use the term to refer to the specific role that the module or step plays in an algorithmic solution.)
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif 3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Functional Equivalence A property of a module that performs exactly the same operation as the abstract step it defines. A pair of modules are also functionally equivalent to each other when they perform exactly the same operation.

 
< previous page page_154 next page >