5. Each class should have one designated
initializer.
Child classes should call it.
Without Two-Stage creation, subclasses
would have to re-implement each
initializer. (Think of NSData or NSString,
which have many initializers...subclassing
each one would be a lot of work.)
11. • Identify steps of an algorithm and one or more
methods to implement each step.
12. • Identify steps of an algorithm and one or more
methods to implement each step.
• Implement the algorithm as a sequence of calls to
the identified methods.
13. • Identify steps of an algorithm and one or more
methods to implement each step.
• Implement the algorithm as a sequence of calls to
the identified methods.
• Factor out the customizable steps of the algorithm
into Template Methods and provide a reasonable
default implementation for each Template Method.
14. • Identify steps of an algorithm and one or more
methods to implement each step.
• Implement the algorithm as a sequence of calls to
the identified methods.
• Factor out the customizable steps of the algorithm
into Template Methods and provide a reasonable
default implementation for each Template Method.
• Document whether the base class’ implementation
of each Template Method can, should or must be
called by subclasses that override them.