Design recipes for methods for simple classes and classes with containment.
Design recipe for methods:
analyze the problem & identify the classes of data (with examples)
formulate a purpose statement and a contract
make up examples of the method invocation - with expected outcomes
create the template: what information exists to compute the desired result?
program
turn the examples into a test suite
We will think carefully about the structure of the templates for each kind of problems:
simple class - no arguments or arguments of primitive type only
simple class - argument is another instance of this class
class with containment - no argument or a primitive argument
class with containment - methods already defined for the contained object
class with containment - argument is another instance of this class
unions of classes - no arguments or arguments of primitive type only
unions of classes - methods already defined for this union
This leads to deciding whether the method for a union of classes should be defined as an abstract method or a concrete method in the abstract class.