Home » Microprocessors and Microcontrollers » What is Modular Programming?

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:

  1. Each module is independent of other modules.
  2. Each module has one input and one output.
  3. A module is small in size.
  4. Programming a single function per module is a goal.

Advantages of Modular Programming

The advantages of modular programming are the following:

  1. It is easy to write, test and debug a module.
  2. Generally modules of common nature are prepared, which can be used at many places.
  3. The programmer can divide tasks and use the previously written programs.
  4. If a change is to be made, it is made in the particular module; the entire program is not affected.
  5. Pieces can be debugged independently.
  6. Work can be divided between multiple programmers.
  7. Code can be reused.
  8. Problems can he reduced to smaller, simpler, humanly comprehensible levels.
  9. Modules can be assigned to different teams/programmers. This enables parallel work, reduces pro­gram-development time, and facilitates programming, debugging, testing and maintenance.
  10. Individual modules are portable; so they can be modified to run on other platforms.
  11. Modules can be re-used within a program and across programs.

Disadvantages of Modular Programming

The disadvantages of modular programming are the following:

  1. The combining of modules together is a difficult task.
  2. It needs careful documentation as it may affect the other parts of the program.
  3. 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.
  4. Modular programming requires extra time and memory.
  5. 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.