The Design Recipe
Using Emacs for Lisp
How to Design Programs
How to Design Programs is a book which provides a clear approach to programming that is test driven and data driven where you first write your purpose as a clear statement, your expectations as explicit tests and then let the data drive your decisions.
The Design Recipe
- Problem Analysis
- Identify the information that must be represented and how it is represented in the chosen programming language. Formulate data definitions and illustrate them with examples.
- Signature, Purpose Statement, Header
- State which data the desired function consumes and produces. Express what the function computes as a concise one-line statement. Define a stub that lives up to the signature.
- Functional Examples
- Work through examples that illustrate the function’s purpose. Write these examples as explicit tests.
- Function Template
- Translate your data definitions into an outline of the function.
- Function Definition
- Fill in the gaps in the function template. Make use of the purpose statement and the examples.
- Testing
- Ensure that the function passes all tests. The tests will also help your successor ensure that the function works for these examples after future modifications.
- Refine, Simplify, Refactor
- Look for opportunities to express your functions more simply or to make them more generally applicable.