The template method pattern

By | March 21, 2018

The template method pattern is a behavioral pattern. That means it is a pattern that cannot clearly be seen from UML as the functionality of the pattern is in the behavior (the implementation)

An UML expression of the pattern might look like this.

In this example the RefinedAbstraction class is inheriting the template method pattern from the Abstract parent. When the TemplateMethod is called the behavioral pattern will invoke PrimitiveOperation1 and PrimitiveOperation2.

In this example we can see that the PrimitiveOperations are protected and overiddable which means the derived type could change the behavior of the method if it wishes to do so.

Leave a Reply

Your email address will not be published.