What is Modular Programming?:
What is Modular Programming? – Generally, industry-programming projects consist of thousands of lines of instructions or operation code. Such huge monolithic programs would be unmanageable and incomprehensible. Therefore, it is difficult to design, write, debug, and test such a project. Hence, the complete project is divided into sub-problems or small modules. Each independent modules are separately named and are individually invokeable proÂgram elements. The sizes of modules are reduced to a humanly comprehensible and manageable level. This approach is known as modular programming. The divide-and-conquer approach is used in programming.
Modules are designed, written, tested and debugged by individuals or small teams to allow for multiple programmers to work in parallel. Modules are integrated to become a software system that satisfies the problem requirements. To integrate successfully, the original decision must be good and interfaces between modules must be correct.
Each module will be different, depending on the specific problem being solved. In very simple problems only one module exists, but complex problems have many hundreds of modules. Modules are written in such a way that everybody understands the program very easily. Generally, a top-down design is used in modular programming. In this programming, high-level instructions are broken down into smaller sets of instructions and again into smaller sets until we get the smallest module. The characteristics of modules are given below:
- Each module is independent of other modules.
- Each module has one input and one output.
- A module is small in size.
- Programming a single function per module is a goal.
Advantages of Modular Programming
The advantages of modular programming are the following:
- It is easy to write, test and debug a module.
- Generally modules of common nature are prepared, which can be used at many places.
- The programmer can divide tasks and use the previously written programs.
- If a change is to be made, it is made in the particular module; the entire program is not affected.
- Pieces can be debugged independently.
- Work can be divided between multiple programmers.
- Code can be reused.
- Problems can he reduced to smaller, simpler, humanly comprehensible levels.
- Modules can be assigned to different teams/programmers. This enables parallel work, reduces proÂgram-development time, and facilitates programming, debugging, testing and maintenance.
- Individual modules are portable; so they can be modified to run on other platforms.
- Modules can be re-used within a program and across programs.
Disadvantages of Modular Programming
The disadvantages of modular programming are the following:
- The combining of modules together is a difficult task.
- It needs careful documentation as it may affect the other parts of the program.
- While testing modules it may be found that the module under test may require data from other modÂules or its results may be used by other modules. To solve such problems, special programs called drivers are to be developed to produce the desired data for the testing of modules. The development of drivers requires extra effort and time.
- Modular programming requires extra time and memory.
- The modular programming was originally developed for writing long programs but this technique can also be used for shorter programs written for microcomputers. Modules are divided on functional lines and hence, they can form a library of programs. Modules of 20 to 50 lines should be developed. They are very useful. There is unnecessary wastage of time in preparing shorter modules. Longer modules are not converted to general nature. The modules should be developed for common tasks. They should be of general form.