Functions and procedures are two of the tools in every programmer’s toolbox that allow him to write tighter, more efficient code. While there may be a downside or two in using this programming option, the advantages far outweigh any disadvantages. By implementing functions and procedures in his program, the programmer reduces coding time and debugging time, thereby reducing the overall development time.
Procedures and Functions
Procedures and functions operate on the same principle of writing a small chunk of code that you can call, rather than writing the same code in multiple places in your program. This practice cuts down on program size at the very least, and often improves the readability of the program. Most programming languages contain built-in functions, and support the capability to build procedures and functions in your code.
Reduced Coding Time
An advantage of using functions and procedures is that coding time is reduced. If you only have to write a routine one time and code statements that call it, you save the time of coding the same routine multiple times, even if you opt to cut and paste the routine. The reduction in coding time helps to reduce the total project delivery time.
Reduced Debugging Time
In addition to reducing coding time, using procedures and functions help to reduce debugging time. When you put the same code in multiple places it is sometimes difficult to make debugging changes in all of those places. If you make the change in one place, but fail to make the change in the other two places it is easy to become confused. This makes it difficult to find the problem and eliminate it from every place in the program.
The effects on program maintenance, which is the most costly of the development stages, can be both good and bad. As with debugging, if the problem is in a called procedure, then you can find it once and eliminate it quickly. However, if the programmer who wrote the code overused procedures and functions, the program can be harder to understand. The harder to understand, the longer it takes to fix a program.