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
- Easy to trace the bugs.
- Easy to traversal the program.
Disadvantages of Procedural Programming
- In large program it is very difficult to identify what data is used by which function.
- It does not allow reusability of code.
Structural Approach
Structural Approach refers to the process in which we break the overall job into separate pieces of modules. This approach is necessary to reduce the complexity of the program. One type of structural approach is Modular approach.
Advantages of Structural Approach:
- Modification or enhancement in programs becomes easier.
- Reduce debugging time.
- Allows several programmers to code simultaneously.
Modular Approach
In this approach, the program is divided into modules. Each module can contain procedures, functions, macros which are related to each other. and the data on which the act. Modular programming is the other name for Data hiding principle. For example, the complete set of operations of a stack including the data structure and functions may reside in a module.
C enables modular programming by providing provision for including files and separate compilation facilities. The context of module is supported by the class concept of C++.
Advantages of Modular Approach:
- Tracing of error is easier.
- Modules can be kept separately in a library and used anywhere in the program without re-writing them.
- A module can use other modules.
- It saves development time as we can reuse the code again and again.
Bottom-up Approach
Bottom up approach starts from the bottom level of operation and then a higher level until the stage is reached.
Advantages of Bottom-up Approach:
- It can handle the increasing complexity of program that are reliable and maintainable.
- It enables programmers to write complex programs easily.
- It is useful when designing the complex systems like operating system, networking software system etc.