Recipes
- Choose function and parameter names.
- Choose the types of the parameters and the type of the output (if any).
- Write the function header, which specifies the names.
- Write the function body, the code for the function.
- Import modules
- Define constants
- List tasks as comments
- Create user-defined functions
- Choose identifiers and types
- Create function header
- Import modules (beginning of program)
- Define constants (beginning of function)
- List tasks as comments
- Fill in details of function tasks
- Fill in details of program tasks
- Identify cases
- Order cases
- Choose conditions
- Simplify
- Are types and meanings of all variables and constants clear?
- Are there any “magic” numbers?
- Is the organization and use of blank lines clear?
- Are the steps indicated using comments?
- Do functions have comments explaining the purpose, preconditions, and postconditions?
- Are there helper functions for repeated and other tasks?
- Are there more parameters that could be added to a function?
- Order functions by dependency
- Test in order of dependency
- Black box testing
- White box testing
- To find sources of error:
- Tracing and visualization
- Print statements
- Narrow focus
- Express the task as iteration.
- Write a condition.
- Ensure initial values of variables checked in the condition.
- Ensure the condition can change in the body of the loop.
- Express the task as iteration.
- Specify starting and ending values.
- Choose meaningful attribute names.
- Choose attribute types.
- Record attribute names and types of attributes.
- Add the method definition to the class definition.
- Make the object the first parameter, with name self.
- Use dot notation for attributes.
- Express the problem in terms of a problem on an input closer to a base case.
- Make sure to have a base case.
- Make sure to have a recursive case.
- Make sure all possibilities are covered.