Showing posts with label Systematic-Program-Design. Show all posts
Showing posts with label Systematic-Program-Design. Show all posts

Tuesday, July 16, 2013

Beyond Systematic Program Design

Next steps beyond Systematic Program Design include:
  1. How to Design Programs, HtDP
  2. Structure and Interpretation of Computer Programs, SICP
  3. Concepts, Techniques, and Models of Programming , CTM

References:


On Systematic Program Design


Key lessons from this course include:
  1. Recipes are extremely useful
  2. Templates are extremely useful
  3. Knowing what needs to be done NOW is extremely valuable
    • It increases productivity tremendously
    • Recipes and templates are what makes this possible 
  4. Data design drives function design drives implementation
  5. Being systematic comes from using good recipes and templates
Key programming practices:
  1. Understand the information domain clearly
    1. Draw diagrams
    2. Write out examples
  2. Map the information domain to data domain
  3. Use check-expects / unit tests
  4. Use wishes to track work outstanding
Key tools:
  1. Recipes
  2. Templates



Data Definition for Tree Structures Using Mutual Recursion

A tree of arbitrary width and depth is defined using mutual recursion.
The figure below shows the mutual reference in the data definition and the corresponding function template.
Also contrast a tree with a list. A tree has arbitrary width and depth which a list has arbitrary length.

Decomposing Functions

When to decompose functions?

  1. Function composition:  A function should be split into a function composition when it performs two or more distinct and complete operations on the consumed data.
    • define arrange-images as a function composition of sort-images and layout-images helper functions.
  2. Operating on a list: When an expression must operate on a list -- and go arbitrarily far into that list -- then it should call a helper function to do that.
    • use the insert-images helper function so that the (first loi) expression can operate on the (rest loi) list, going arbitrarily far into that list as needed.
  3. Domain knowledge shift: When the body of a function must shift to a new knowledge domain, it should call a helper function to do the work in the new domain.
    • use the (larger? img1 img2) helper function when shifting from the domain knowledge of inserting images to domain knowledge of determining size of images.