Template Pattern

Learn how to use the Template pattern to create different configuration managers supporting different file formats.

The pattern that we’re going to analyze next is called the Template pattern and it has a lot in common with the Strategy pattern. The Template pattern defines an abstract class that implements the skeleton (representing the common parts) of a component, where some of its steps are left undefined. Subclasses can then fill the gaps in the component by implementing the missing parts, called template methods. The intent of this pattern is to make it possible to define a family of classes that are all variations of a family of components. The following UML illustration shows the structure that we just described:

Get hands-on with 1200+ tech skills courses.