On this page:
How To Use The Design Recipe
Definition
Interpretation
Examples
Template
Signature
Purpose Statement
Functional Examples/  Tests
Code
The Design Recipe In The Textbook

The Design Recipe

Data

  

Functions

Definition

  

Signature

Interpretation

  

Purpose Statement

Examples

  

Tests

Template

  

Code

How To Use The Design Recipe

The design recipe is here to help you design programs properly. When beginning to solve a new problem, the first question to ask yourself is: do I need a new type of data? If so, follow the steps in the Data column for every new type of data you need. When writing functions, follow the steps in the Function column for every function you write.

Note that "do I need a new type of data?" can often be answered with the question "can I write the signature of the function I want to write?"

Below are helpful questions to ask yourself when tackling a specific step of the DR:

Definition

Interpretation

Examples

Template

Signature

Purpose Statement

Functional Examples/Tests

Code

The Design Recipe In The Textbook

As you may have noticed, the layout of the design recipe above (in table format) is different than what is found in the textbook.

In the textbook, there is a list of six steps described as the design recipe for functions:
  1. Express how you wish to represent information as data.

  2. Write down a signature, a statement of purpose, and a function header.

  3. Illustrate the signature and the purpose statement with some functional examples.

  4. Replace the function’s body with a template.

  5. Code.

  6. Test your code.

However, we feel the tabular display of the design recipe is somewhat clearer, as it breaks out which steps are related to data design and which steps are related to functions.

The representation seen above is derived from textbook representation as follows: Step 1, in regards to representing data, becomes the data definition and interpretation. Step 2 becomes the signature and purpose statement. Steps 3 and 6 become the tests, and step 3 also becomes examples. Step 4 is now the template step. Step 5 is now the code step.

The list as given in the book interweaves both data design and function design, and having the two displayed separately shows that they can be done independently of each other. It also makes it clear that templates and examples need to be written once for each data definition, as opposed to for each function, and that every function should have a signature, purpose statement, and tests.

There is also a parallel between the two columns of the table:
  • Data definitions and signatures both specify types of data.

  • Interpetations and purpose statements both clarify the intent of code in english.

  • Examples drive tests.

  • Templates drive code.