Examples
Write down one or more expressions that use this function
(in correct Scheme syntax, so that if only the function
were already defined, you could type them in and get answers),
along with the "right answer" you expect each example to
produce. This step is useful in at least three ways.
- It allows you to try
out the syntax people will use to invoke the function, and perhaps learn
that your first guess at the syntax is inconvenient to use, so you
should change the syntax before wasting a lot of time implementing it.
- It allows you to discover, early on, that your contract wasn't
quite right, and that you actually want different kinds of information
going in or out. If that happens, change the contract now and
re-write your examples accordingly; that will waste less time than going
on and having to change the contract later.
- It gives you a ready source of test cases, already in legal Scheme
syntax, thus removing one possible excuse for skipping the
Testing step, below.
Start with the simplest possible examples, then work up to more and more
complicated examples. Again, write your examples in a Scheme comment,
e.g.
; (cube 0) => 0
; (cube -3/5) => -27/125
; (cube (cube 3)) => 19683
Last modified:
Thu Jun 1 15:59:59 EDT 2000
Stephen Bloch / sbloch@adelphi.edu