Details for Thursday Morning
Morning Lecture
Scheme vs DrScheme vs TeachScheme!
what's difficult? what's programming?
problem solving w/o system is an accident
the more stringent the constraints, the higher the degree of creativity
creativity w/o technique doesn't exist
"style is personal implementation/interpretation of technique"
---------------------------------------------------------------------------------
The Design Recipe Revisited: data-driven; template oriented
Data Analysis:
what form of information must be represented?
do any "object descriptions" require compounding of any kind?
formulate data definitions
Contract
what data goes in? what comes out?
Examples
make up examples of possible inputs
what are the matching outputs?
Header
Template
how many different kinds of data?
if more than one, probably use COND
how do we distinguish them?
how do we access the fields?
Do we need to recur?
Body
what is the purpose of the function?
formulate expressions for atomic inputs
formulate expressions for non-recursive cases
formulate expressions for recursive cases:
what does the recursion compute?
how can we use the result of the recursion and the remaining pieces
to compute the final result?
Test
---------------------------------------------------------------------------------
Web pages:
wp = empty | (cons sym wp) | (cons wp wp)
examples of web pages
;; word-count : wp -> num
how to distinguish among the last two alternatives
---------------------------------------------------------------------------------
Evaluate expresions:
exp = num | (exp + exp) | (exp - exp)
information to data: make-plus, make-minus
let's count num's, op's, +'s ...
==> continue in LAB
Morning Lab:
RECAP: Data-driven design
ASSIGNMENT:
;; count-num : exp -> num
;; value-of : exp -> num
NOW: extend exp:
(+ exp exp exp) : what needs to change? --> the variant for +
(* exp exp) : what needs to change? --> one new cond-line in every
function that consumes exp
symbol : a representation for variables --> one new cond-line again
Add the following programs:
;; subst : exp var number -> exp
;; closed: exp -> boolean
;; value-of: exp -> num