[PLT logo] TeachJava!

The Java Design Recipe

  1. Define the data.
  2. For each class, determine the methods that process that form of data and write the signature (contract and header) for the corresponding method. 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.

  3. For each program method, write a purpose statement specifying what the method requires and what it produces. Attach this statement as a comment to the most general declaration of the corresponding method.

  4. For each program method m, give a collection of examples specifying how you expect that method to behave. Write these examples as test cases in a test method for m.

  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 class, write the body for each method in the class, recognizing that self-references in the class of the method suggest that recursive delegation is appropriate.

  7. Test each method using the Test classes for the program. Include additional test cases suggested by issues that arose during coding and testing.