Modular programming
When a program is short and simple, there is no need to break it up into subroutines. With a long, complex program, however, a top-down approach, in which the problem is broken down into a number of subtasks, is generally very helpful in designing the algorithm for a satisfactory solution
Programming with subroutines
Using subroutines in a large program has many advantages:
- A subroutine is small enough to be understood as a unit of code. It is therefore relatively easy to understand, debug and maintain especially if its purpose is clearly defined and documented.
- Subroutines can be tested independently, thereby shortening the time taken to get a large program working.
- Once a subroutine has been thoroughly tested, it can be reused with confidence in different programs or parts of the same program.
- In a very large project, several programmers may be working on a single program. Using a modular approach, each programmer can be given a specific set of subroutines to work on. This enables the whole program to be finished sooner.
- A large project becomes easier to monitor and control