Systematic Program Design (HTDP) Flashcards
1
Q
What are the steps of the “HtDf” recipe?
A
- signature, purpose, stub
- Define examples, then code them as tests.
- Template and inventory.
- Code function body.
- Test and debug until correct.
2
Q
How many steps are there to the HtDf recipe?
A
5 steps.
3
Q
How many steps are there to the recipe to design abstract functions from examples?
A
There are 7 steps. Step number 2 has 1 sub-steps and step number 4 has 3 sub-steps.
4
Q
What are the steps of the recipe to design abstract functions from examples?
A
- Identity multiple repetitive expressions.
- Introduce a new generically named function around a copy of the repetitive expression.
- if the expression is the body of a recursive function, then replace each recursive call w/ the new function name. - Identity one or more points of variance in the repetitive expressions and replace each w/ a new parameter in the new function.
- Develop examples/tests for the new function.
- adapt any available tests that exercise the initial repetitive expression.
- make sure to test variability
- attempt to test the behavior of the new function beyond that exercised by original tests. - Compose an abstract purpose based on the examples/tests.
- Infer an abstract function signature using type parameters.
- Replace initial repetitive expressions with calls to the new function.
5
Q
How many steps are there in the recipe for designing abstract functions from a data type signature?
A
there are 5 steps.
6
Q
What are the steps for designing abstract functions from a data type signature?
A
- start with the appropriate template for the data type. If the templates are mutually referential, make sure they are wrapped within a single function.
- replace each placeholder (i.e. …) in the template with a new parameter.
- develop examples/tests for the function
- Compose an abstract purpose based on examples/tests.
- Deduce an abstract function signature using type parameters.