How does using functions make writing large programs easier?

Consider a program with 1000 lines. It is much easier to write a properly designed program consisting of 20 50-line functions than it is to write a program consisting of one 1000-line main program.

Functions can be written, tested, and understood independently of one another. You can write a function, test it, and convince yourself that it is correct without worrying about the other functions in your program. It is much easier to get your mind around a 50-line thing than a 1000-line thing.

Another benefit is that code can be reused between projects. If someone has previously written a function that you would like to use, it is a simple matter to incorporate it into your program. This is more so in domain specific functions, ex. Banking.

A third benefit is that the use of functions can eliminate the duplication of code. If the duplicated code is long enough, the use of functions can actually shorten a program.

A multi-person programming project proceeds by first deciding what functions need to be implemented, and then implementing the functions. Once the functions are designed, they can be divided up among the available programmers and implemented separately. Compare that with having multiple programmers work on a single main program.

You may also like...

1 Response

  1. March 17, 2014

    […] see: How does using functions make writing large programs easier? Coding Standards for Writing […]

Leave a Reply

Your email address will not be published. Required fields are marked *

FREE C Programming Cheatsheet

FREE C Programming Cheatsheet


Cheatsheet for a quick glance at C programming concepts and syntax

Thank you! Check you inbox and access your cheat-sheet