How to Build a Program
Building a program is not an art, it is an engineering process.
As such there is a process to follow with clearly defined steps.
Analysis (Understand the Requirements)
In this class you will be given the problem requirements, unlike the
real-world where you have to elicit the requirements from a
customer. For you the first step will be to read the problem and
be sure you understand what the program must do. Summarize your
understanding by writing the Input data, Output data, and Functions
(operations or transformation on the data).
Create a Test Plan
You must be able to verify that your program works correctly once it is
written. Invent some actual input data values and manually
compute the expected result.
Invent a Solution
This is the creative, exploratory part of design where you figure out
how to solve the problem. Here is one strategy:
- Solve the problem manually, the way you would do it as a human.
- Pay careful to attention what operations you perform and write
down each step.
- Look for a pattern in the steps you performed.
- Determine how this pattern could be automated using the 3
algorithm building blocks (Sequence, Selection, Iteration).
Design (Formalize your solution)
Arrange your solution into components; this is called the architecture.
Write the algorithm for each component. Refine your algorithm in
a step-wise manner if necessary.
Determine the data types and constraints for each data item.
Perform a hand trace of your solution and simulate how the computer
will carry out your algorithm. Make sure your algorithm works
correctly before you put it into the computer.
Translate your algorithm into a programming language and enter it into
Compile your source code to produce an executable program.
You may want to compile and test each subprogram individually
before combining them into a complete program.
Execute the program using the Test Plans you created above.
Correct any errors as necessary.