Program Design Recipe
To write a program one follows a recipe of steps. Here are the steps
we will use for all our programs.
- Each step is a concrete activity
- Each step has a product that can be inspected
Here are the steps we will follow:
- Understand the problem.
Often the analysis is inserted in the program as a comment.
- Write a contract for each function about how its inputs and outputs behave.
In Haskell, a contract is written using a typing prototype.
- Create a set of examples. We will use HUnit assertions as the product
that encodes examples.
- Write the body of each function. Use the guideline that the structure
of the body follows the structure of the input data.
- Testing. Test your program. We will use HUnit tests
as the testing product. Later we will learn how to use QiuckCheck random testing as additonal testing
products.
If you do not have all the products then you have not followed the design
recipe, and you are much more likely to make mistakes.
Back to the Daily Record.
Back to the class web-page.