Systematic Program Design (HTDP) Flashcards

1
Q

What are the steps of the “HtDf” recipe?

A
  1. signature, purpose, stub
  2. Define examples, then code them as tests.
  3. Template and inventory.
  4. Code function body.
  5. Test and debug until correct.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How many steps are there to the HtDf recipe?

A

5 steps.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the steps of the recipe to design abstract functions from examples?

A
  1. Identity multiple repetitive expressions.
  2. 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.
  3. Identity one or more points of variance in the repetitive expressions and replace each w/ a new parameter in the new function.
  4. 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.
  5. Compose an abstract purpose based on the examples/tests.
  6. Infer an abstract function signature using type parameters.
  7. Replace initial repetitive expressions with calls to the new function.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How many steps are there in the recipe for designing abstract functions from a data type signature?

A

there are 5 steps.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the steps for designing abstract functions from a data type signature?

A
  1. start with the appropriate template for the data type. If the templates are mutually referential, make sure they are wrapped within a single function.
  2. replace each placeholder (i.e. …) in the template with a new parameter.
  3. develop examples/tests for the function
  4. Compose an abstract purpose based on examples/tests.
  5. Deduce an abstract function signature using type parameters.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly