March 2002
Intermediate to advanced
496 pages
8h 51m
English
When you apply TEMPLATE METHOD, classes in a hierarchy share the outline of an algorithm that you or someone else codes in an abstract superclass. The opportunity for TEMPLATE METHOD may also crop up when you implement similar algorithms in more than one method. Consider the Machine and MachinePlanner parallel hierarchy that you worked with in Chapter 16, Factory Method. As Figure 21.4 shows, the Machine class provides a createPlanner() method as a FACTORY METHOD that returns an appropriate subclass of MachinePlanner.

Suppose ...
Read now
Unlock full access