|
|
|
|
|
|
|
Figure 1-14
Means-Ends Analysis |
|
|
|
|
|
|
|
|
get from Boston to Newark. Now you only have to examine the means of meeting that intermediate goal (see Figure 1-14). |
|
|
|
|
|
|
|
|
The overall strategy of means-ends analysis is to define the ends and then to analyze your means of getting between them. The process translates easily to computer programming. You begin by writing down what the input is and what the output should be. Then you consider the actions a computer can perform and choose a sequence of actions that can transform the data into the results. |
|
|
|
|
|
|
|
|
We often break up large problems into smaller units that are easier to handle. Cleaning the whole house may seem overwhelming; cleaning the rooms one at a time seems much more manageable. The same principle applies to programming. We break up a large problem into smaller pieces that we can solve individually (see Figure 1-15). In fact, the top-down methodology and the object-oriented methodology, which we describe in Chapter 4, are based on the principle of divide and conquer. |
|
|
|
|
|
|
|
|
The Building-Block Approach |
|
|
|
|
|
|
|
|
Another way of attacking a large problem is to see if there are any existing solutions for smaller pieces of the problem. It may be possible to put some of these solutions together end to end to solve most of the big problem. This strategy is just a combination of the look-for-familiar-things and divide-and-conquer approaches. You look at the big problem and see that it can be divided into smaller problems for which solutions already exist. Solving the big problem is just a matter of putting the existing solutions together, like mortaring together blocks to form a wall (see Figure 1-16). |
|
|
|
|
|