Contract
Decide what kind of information the function needs from the
outside world, and what kind of information it returns to
the outside world. Ask the following questions:
- How many pieces of information (parameters) does it need to be
given in order to do its job?
- What kind(s) of information are the various parameters? (At
present, the only kinds of information we know about are numbers
and Booleans.)
- What kind of information, if any, does it return as a value?
I usually write the answers in the definitions window as a Scheme comment
in a standard format: for example,
; cube : number => number
would indicate a function named "cube" requiring a numeric
parameter and returning another number.
; area-of-ring : number (inner radius), number (outer radius) => number
would indicate that the function named "area-of-ring" expects
two numeric parameters, an inner radius and an outer radius (in that order),
and returns a number.
Last modified:
Thu Jun 1 15:49:36 EDT 2000
Stephen Bloch / sbloch@adelphi.edu