Top Down Approach (or) Stepwise Refinement
https://www.computersprofessor.com/2016/05/top-down-approach-or-stepwise-refinement.html
Program development includes
designing, coding , testing & verification of a program in any computer
language for writing a good program, the top down approach can be used.
It is also known as systematic
programming (or) hierarchical program design (or) step-wise refinement.
A complex problem is broken into
smaller sub problems. Further each sub problem is broken into a no of smaller
sub problems & till the sub problems at the lowest level are easy to solve.
Similarly a large program is broken
into no of subprograms and in turn each sub program is further decomposed into
sub programs and so on.
Suppose we want to solve a problem
S, which can be decomposed into sub problems s1, s2, s3
and so on. Let the program for s, s1, s2, s3
be denoted by p, p1, p2, p3 respectively.
Further suppose
that s2 is solved by
decomposing it into sub problems s21&s22&
programs p21, p22 . One written for these. This operation
of coding a subprogram in terms of lower level sub programs is known as the
process of step wise refinement.
The following figure shows the
hierarchical decomposition of P into its subprograms & sub subprograms.
Step-wise Refinement
The advantages of
the Top–Down design approach are:–
1. A large
problem is divided into a no of smaller problems using this approach. The
decomposition is continued till the sub problems at the lowest level become
easy to solve. So the overall problem solving becomes easy.
2. If we use
the top–down for a problem than top–down programming method can be used for
coding modules at various stages. So, the top level modules can be coded
without coding the lower level modules earlier. This approach, is better than
the bottom–up approach where programming starts first at lowest level modules.
3.If helps is
top–down testing & debugging of programs.
4. The programs
become uses friendly (i.e., easy to read & understand) & easy to
maintain & modify.