In the article The computer programming process we briefly described the following stages in the development of a computer program:
(1) Define the problem.
(2) Analyze the problem.
(3) Develop an algorithm (a method) for solving the problem.
(4) Write the computer program which implements the algorithm.
(5) Test and debug (find the errors in) the program.
(6) Document the program. (Explain how the program works and how to use it).
(7) Maintain the program.
We now take a more detailed look at each of these stages. In this article, we describe the first three.
Suppose we want to help a child work out the areas of squares. This defines a problem to be solved. However, a brief analysis reveals that the definition is not complete or specific enough to proceed with developing a program. Talking with the child might reveal that she needs a program which requests her to enter the length of a side of the square; the program then prints the area of the square.
We further analyze the problem to;
(a) ensure that we have the clearest possible understanding of it;
(b) determine general requirements such as the main inputs to the program and the main outputs from the program. For more complex programs, we would, for instance, also need to decide on the kinds of files which may be needed. (Think of a file as a place in the computer used for storing things like documents, pictures, programs, even songs and movies.)
If there are several ways to solve the problem, we should consider the alternatives and choose the best or most appropriate one.
In this example, the input to the program is the length of one side of the square and the output is the area of the square. We only need to know how to calculate the area. If the side is s, then the area, a, is calculated by:
a = s x s