What is Template Pattern?
Template pattern, an abstract class exposes a ways to execute its methods. The subclasses can override the method implementation as per need but the invocation is to be in the same way as defined by an abstract class
When to use Template Pattern?
- When behaviour of an algorithm can vary, you let subclasses implement the behaviour through overriding
- You want to avoid code duplication, implementing variations of the algorithm in subclasses
- You want to control the point that subclassing is allowed.