It is a technique where a long and complex program is split into a number of smaller parts also known as Modules. A module in itself is a complete program, which can be compiled and tested separately. Every module in a program is designed to perform a specific task.
A module may be split into further modules called sub-modules. Conversely, a number of modules may be combined together to form a superior module. The programming languages using the modular programming approach must provide facilities for defining modules and also for calling sub-modules is known as calling statements.
However, in the context of modular programming, it is necessary that when a superior module calls a sub-module, through a calling statement, the control must return to the statement next to the calling statement, after the called module is executed. Thus, modular programming prohibits the use of the GOTO statement as a calling statement, because the use of this statement does not automatically return the control to the calling module.
Advantages of Modular Programming:
- It is easier to test and debug a long program by testing and debugging the individual modules in the program.
- A modular program is easy to understand as the user has to analyze the individual modules which in itself are small programs, each performing a specific task rather than analyzing the entire program.
- It is convenient to modify a modular program by modification or replacement of individual modules without disturbing the entire program.
- Many programmers can work at the same time on a large program as each individual module can be developed separately in isolation. Thus, parallel designing of the modules speeds up the program design job.
- Modules may be developed in a general way so that these can be used with other programs also. In this way, a library of standard and commonly used modules can be developed for future use.
Disadvantages of Modular Programming:
- May need more memory space.
- Requires more effort during design.
- Requires a lot of effort to learn because of the limited number of formal design methods.
- May require more run time.