ITEC120
the design recipe
The design recipe1
is a series of steps to guide you through writing a program.
Not only does it get you past any initial blank-screen anxiety,
but its structure helps guide your thinking in a way which reduces
the number of bugs you'll encounter.
This recipe will get further fleshed out as the semester progresses.
-
Data analysis---What are the pieces of information
at hand, for this problem, and
which data types should be used to represent them in the program?
(E.g., int, String,
boolean, ...?)
-
(Nothing, for the moment…)
-
Purpose and header---for each method (function),
specify its name, what inputs (parameters) it will take,
write a purpose statement explaining what the method will return.
This statement should mention each parameter by name.
-
Test cases:
Decide what methods (functions) you'll want to compute,
what information they need to be given, and what they should answer.
This step is sometimes given to you directly in the assignment-statement,
but eventually you'll need to come up with it.
-
The body of the function. This is the
-
Test---run the test cases you already wrote down
from step 2.
Does your program give the results you expect?
-
Refactor---review and (as necessary) rewrite your
code. Does it obey the Laws of Programming?
1This design recipe
is adapted from How to Design Programs,
by Felleisen, Findler, Flatt, and Krishnamurthi.
back