Programming Approach

Programming Paradigm

The systematic and organized principle of writing a program is called as programming paradigm. It contains Procedural programming approach, Structural programming approach and Modular programming approach.

Procedural Programming Approach

In Procedural Programming, the problem is viewed in a sequence manner. It follows the concept of top-down approach. In procedural programming, we divide a problem into sub-problems recursively and then we write a procedure for each sub-problem. Procedures communicate with each other by parameters. In this approach, data is declared locally or globally. Pascal and C support this programming approach. For example, if you want to implement a stack, you divide the problem into smaller problems like how to push value in a stack, how to pop a value and how to find whether stack is full or empty. Then you write functions for Push, Pop, stack empty and stack full and call these functions using its parameters to implement a stack in a program. The stack size is declared in main program using a data structure (may be an array).

Advantages of Procedural Programming

  1. Easy to trace the bugs.
  2. Easy to traversal the program.

Disadvantages of Procedural Programming

  1. In large program it is very difficult to identify what data is used by which function.
  2. It does not allow reusability of code.

Structural Approach

It is an approach for writing programs which when adopted, makes the logical-steps of the program simple and much more understandable. So that not only the writer of the program understands it but it is easy for other programmers to follow the logic.

Advantages of Structural Approach:

  1. Modification or enhancement in programs becomes easier.
  2. Reduce debugging time.
  3. Allows several programmers to code simultaneously.
  4. Clarity: Structured Programming generally have clarity and more logical and easy to follow.
  5. Productivity: This helps the programmer and others, understanding the logic in the part of the development life cycle.
  6. Maintenance: The Clarity and modularity of a Structured Design helps in finding the bug in the program or redesigning the program during the maintenance phase.

Disadvantage of Structural Approach:

  1. Inefficiency: Sometimes Structured approach requests more code to be written.
  2. Difficulty: To achieve this is very difficult

Modular Approach

In this approach, the program is divided into modules. Each module can contain procedures, functions, macros which are related to each other. A Modular can be designed coded and debugged separately with minimum amount of interaction.

C enables modular programming by providing provision for including files and separate compilation facilities.

C++ enables modular programming by providing the concept of classes and objects.

Advantages of Modular Approach:

  1. Tracing of error is easier.
  2. Modules can be kept separately in a library and used anywhere in the program without re-writing them.
  3. A module can use other modules.
  4. It saves development time as we can reuse the code again and again.

Top Down Approach

Top down approaches emphasize planning and a complete understanding of the system. It is essential that no coding can begin until a sufficient level of detail has been reached in the design of at least some part of the system. The top-up approach is done by attaching the stubs in place of the module. However, this delay testing of the ultimate functional units of a system until significant design is complete.

Top up design was promoted in 1970's by IBM researchers Harlan Mills and Nucleus Wirth.

Top Down Top down design basically an approach follows the following steps:

  1. Overall aspect of system is studied.
  2. Complete task is broken down into independent sub modules.
  3. Process of breaking is related till one obtains modules, which are small enough to grasp mentally and code at one sitting in a straightforward uncomplicated manner.
  4. In the hierarchy of modules, development starts from the top and follows till bottom.

Advantages of Top-down Approach:

  1. Separating the low-level work from the higher-level abstractions leads to a modular design.
  2. Modular design means development can be self-contained
  3. Having skeleton code illustrates clearly how low-level module integrate
  4. Fewer operation errors
  5. Much less time consuming
  6. Very optimized way of processing
  7. Easy to maintain.

Bottom-up Approach

Bottom up approach starts from the bottom level of operation and then a higher level until the stage is reached. In bottom approach the base elements are linked together to form larger subsystems, which are linked sometimes in many levels till a complete top-level system is formed.

Bottom Up In this approach one first visualizes a typical system design and decided by experience, intuition or some analysis that which parts of the design are most difficult and essential ones. In this approach each module is coded as soon as its design is fixed. This type of approach is mostly followed while developing the software for operating systems, where one has to first develop the software for handling primitive calls. Using these programs upper layers is developed and using these layers next higher-level software's are developed.

Advantages of Bottom-up Approach:

  1. It can handle the increasing complexity of program that are reliable and maintainable.
  2. It enables programmers to write complex programs easily.
  3. It is useful when designing the complex systems like operating system, networking software system etc.
  4. Reusability of code