It is easy to study the rules of overloading and of templates without noticing that together they are one of the keys to elegant and efficient type-safe containers.
All the great legends are Templates for human behavior. I would define a myth as a story that has survived.
I work out the other bits, too, but I need to know what I look like, very early on. And then it’s like a template; I’ll fill that person out. If I get that out of the way, then I’m all right.
First of all, you need to differentiate between the
Template Method as a design pattern and the
templateMethod()—a class method—used within a
Template Method pattern. The
templateMethod() is a concrete method within an
abstract class. It orders the sequence of abstract methods, leaving the
implementations up to a concrete class. At its core, the Template Method
defines the skeleton of an algorithm in an operation while the exact
implementations are left up to the concrete classes.
The good thing about the Template Method is that it is relatively small and easy to implement. A single abstract and concrete class is all you need, as shown in Figure 9-1.
One way to think of the template method operation in the abstract class is as an arranger of primitive operations. (I will ...