1. From Problem Analysis to Data Definitions
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.
2. Signature, Purpose Statement, Header
State what kind of data the desired function consumes and produces. Formulate a concise answer to the question what the function computes. Define a stub that lives up to the signature.
3. Functional Examples
Work through examples that illustrate the function’s purpose.
4. Function Template
Translate the data definitions into an outline of the function.
5. Function Definition
Fill in the gaps in the function template. Exploit the purpose statement and the examples.
6. Testing
Articulate the examples as tests and ensure that the function passes all. Doing so discovers mistakes. Tests also supplement examples in that they help others read and understand the definition when the need arises—and it will arise for any serious program.