TeachJava!
The Java Design Recipe
- Define the data.
- Determine what forms of data will the program process.
- Write precise definitions in English for each such form of data.
- Implement these definitions as classes. Include constructors,
accessors, and definitions of appropriate toString methods.
- Define examples of each form of data in Test class corresponding
to the form of data; for mixed data, construct a Test class
for the most general "union" class.
- Include code in the test methods to test the constructors, accessors
and toString() methods.
- 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.
- 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.
- 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.
- For each program method, select an appropriate template,
recognizing that self-references in the class of the method
suggest that recursive delegation is appropriate.
- 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.
- Test each method using the Test classes for the program.
Include additional test cases suggested by issues that arose during
coding and testing.