Page 197 - Open Soource Technologies 304.indd
P. 197
Unit 8: Understanding Function and Procedure
several simpler problems depicted as modules. Any modules that remain too complex are broken
down further. The process of refining modules continues until the smallest modules can be coded
directly. Each stage of refinement adds a more complete specification of what tasks must be
performed. The main idea in top-down design is to go from the general to the specific. This
process of dividing and organizing a problem into tasks can be pictured using a hierarchy chart.
When using top-down design, certain criteria should be met:
1. The design should be easily readable and emphasize small modules size.
2. modules proceed from general to specific as you read down the chart.
3. The modules, as much as possible, should be single minded. That is, they should only
perform a single well-defined task.
4. modules should be independent of each other as much as possible, and any relationships
among modules should be specified.
Write a program for using modules in visual basic.
This process is illustrated with the following example:
1: The chart in Figure 8.2(a) is a hierarchy chart for a program that gives certain
information about a car loan. The inputs are the amount of the loan, the
duration (in years), and the interest rate. The output consists of the monthly
payment and the amount of interest paid during the first month. In the
broadest sense, the program calls for obtaining the input, making calculations,
and displaying the output. Figure 8.2(a) shows these tasks as the first row of
a hierarchy chart.
Car
loan
Get Make Display
input calculations results
Figure 8.2(a): Beginning of a Hierarchy Chart for the Car Loan Program.
Each of these tasks can be refined into more specific subtasks. (See Figure for
the final hierarchy chart.) Most of the subtasks in the third row are
straightforward and so do not require further refinement. For instance, the first
month’s interest is computed by multiplying the amount of the loan by one-
twelfth of the annual rate of interest. The most complicated subtask, the
computation of the monthly payment, has been broken down further. This task
is carried out by applying a standard formula found in finance books; however,
the formula requires the number of payments.
LOVELY PROFESSIONAL UNIVERSITY 191