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:
  1. How many pieces of information (parameters) does it need to be given in order to do its job?
  2. What kind(s) of information are the various parameters? (At first, the only kinds of information we know about are numbers and Booleans.)
  3. 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: Wed May 30 11:48:56 EDT 2001
Stephen Bloch / sbloch@adelphi.edu