October 30, 2003

Behavioral Pattern – Template Model

The Template pattern allows the building of a class or algorithm that can operate on multiple classes that support a predefined set of methods.

• The template class only uses these methods and other primitives to build functionality.

• The advantage of this pattern is that code that is identical, except the type of object that it operates on, can be written only once, instead of having to be written for every possible type.

• Templates are natively supported by many languages, and ATL and STL are built entirely on the template pattern.

Links:

http://www.dofactory.com/Patterns/PatternTemplate.aspx

Template Method pattern discussion