Complex problems can thus be solved using top-down design,
also known as stepwise refinement, where we:
1. Break the problem into parts.
2. Then break the parts into parts.
3. Solve each of the parts, which will be easy to do.
2.5.2 Advantages of Top-Down Design
Breaking the problem into parts helps us to clarify what needs to be
done, and at each step of refinement, the new parts become less
complicated and therefore easier to figure out. Thus parts of the
solution may turn out to be reusable. Breaking the problem into
parts also allows more than one person to work on the solution. By
separating the low-level work from the higher level objects, the
design becomes modular, which means development can be
self-contained. A top-down modular approach means you create a
“skeleton” code that illustrates clearly how low-level modules inte-
grate. This approach also reduces coding errors, because each
module has to be processed separately.
2.5.3 Non-MEL Example of Top-Down Design
We own a home improvement company.
We do painting, roofing, and basement waterproofing.
A section of town has recently flooded (zip code 21222).
We want to send out pamphlets to our customers in that area.
1. Get the customer list from a file.
2. Sort the list according to zip code.
3. Make a new file of only the customers with the zip code 21222
from the sorted customer list.
4. Print an envelope for each of these customers.