...

/

The Template Method

The Template Method

Learn about a behavioral design pattern: the template method.

The template method is a behavioral pattern that yields important benefits when implemented properly. Mainly, it allows us to reuse code, and it also makes our objects more flexible and easier to change while preserving polymorphism.

Press + to interact

How the template pattern works

The idea is that there is a class hierarchy that defines some behavior; let's say that's an important method of its public interface. All of the classes of the hierarchy share a common template ...