[PLT logo] TeachJava 2004

The Java Design Recipe

  1. Define the data.
  2. For each class, determine the methods that process that form of data and write their signatures (headers) in the class bodies. For any method that is defined for mixed data, include a abstract method signature in the most general class for which the method is defined and concrete method signatures in all of the concrete classes where it is defined.

  3. Write contracts (purpose statements) for all of the non-trivial methods in your program specifying what they require and they produce. Attach each contract as comment to the most general declaration of the corresponding method.

  4. For each program method m, devise a collection of examples specifying how you expect that method to behave. Write these examples as test methods in a JUnit test case class.

  5. For each program method, select an appropriate template, recognizing that self-references in the class of the method suggest that recursive delegation is appropriate.

  6. For each program method, write the body, recognizing that self-references in the class of the method suggest that recursive delegation is appropriate.

  7. Test each method (from step 2.) using the JUnit test case classes for the program. Include additional test cases suggested by issues that arose during coding and testing.