The template method pattern

By | Mar 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.

0 0 vote
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments