Help!
Next: Definition Before Use
Up: Functions
Previous: A Simple Function

Why Functions?

There are several questions that you should always ask whenever anyone gives you advice about writing programs:

  1. Writing small programs is easy. Does the advice make writing large programs easier?

  2. Writing a program by yourself is much easier than writing one with others. Does the advice make cooperative programming easier?

  3. Writing a program is much easier than understanding or modifying a program written by others (or even by yourself). Does the advice make it easier to understand and modify existing programs?

Dividing programs into functions satisfies all of these questions. Let's consider each question in turn.

How does using functions make writing large programs easier?

Click here for an answer

How does using functions make cooperative programming easier?

Click here for an answer

How does using functions make modifying programs easier?

Click here for an answer

If you do not have much programming experience, these explanations might not be very convincing. In the larger scheme of things, learning a programming language like C is easy. A professional programmer will learn many programming languages over the course of a career. Much more difficult is the process of designing a program so that it can be divided into small modules (such as functions) and then managing the implementation of the program by multiple programmers. This is known as software engineering. There are lots of programmers in the world, but not very many good software engineers.


Help!
Next: Definition Before Use
Up: Functions
Previous: A Simple Function

Hamlet Project
hamlet@cs.utah.edu