Chapter 4 - Programming Methodologies
Chapter 4 - Programming Methodologies
Alternative
1) Imperative: the emphasis is on the operations intended as actions/commands/instructions that
change the state of the computation; the objects are functional to the computation;
2) Functional: the emphasis is on the operations intended as functions that compute results; the
objects are functional to the computation;
3) object oriented: the emphasis is on the objects, which as a whole represent the domain of interest;
the operations are functional to the representation.
a) Procedural Programming: Problem is broken down into procedures, or blocks of code that
perform one task each. All procedures taken together form the whole program. It is suitable only
for small programs that have low level of complexity. Example − For a calculator program that
does addition, subtraction, multiplication, division, square root and comparison, each of these
operations can be developed as separate procedures. In the main program each procedure would
be invoked on the basis of user’s choice.
b) Functional Programming: Here the problem, or the desired solution, is broken down into
functional units. Each unit performs its own task and is self-sufficient. These units are then
stitched together to form the complete solution. Example − A payroll processing can have
functional units like employee data maintenance, basic salary calculation, gross salary
calculation, leave processing, loan repayment processing, etc.
For each of the methodologies discussed, problem has to be broken down into smaller units. To do this,
developers use any of the following two approaches
1) Top-Down Approach
2) Bottom-up Approach
Top-down-design starts with a description of the overall system and usually consists of a hierarchical
structure which contains more detailed descriptions of the system at each lower level. The lower level
design details continue until further subdivision is no longer possible, i.e., until the system is described in
terms of its "atomic" parts. This method involves a hierarchical or tree-like structure for a system as
illustrated by the following diagram:
Bottom-up emphasizes coding and early testing, which can begin as soon as the first module has been
specified. This approach, however, runs the risk that modules may be coded without having a clear idea of
how they link to other parts of the system, and that such linking may not be as easy as first thought. Re-
usability of code is one of the main benefits of the bottom-up approach