The Template Method design pattern involves implementing an abstract method in a superclass and a concrete method with the same name in the subclasses. Other code that calls the method can use the protocol from the superclass and trust that it's properly implemented in the subclass. I find the Template Method a rather strange design pattern. The technique is so pervasive that I barely think of it as a design pattern. It's just the way things are done in object oriented designs. It reminds me of Kent Beck's style of design patterns. According to Kent, patterns should be smaller and much less grandiose. Lazy initialization, accessor methods, and guard clauses are considered design patterns according to this definition. Most of the other design patterns in the gang of four book are more involved, but there is an appeal to have smaller and simpler patterns.
Download