Java Template pattern
The Template pattern formalizes the idea of defining an algorithm in a class, but leaving some of the details to be implemented in subclasses.
Reasons for using Template pattern:
Let subclasses implement behavior that can vary.
Avoid duplication in the code, the base class contains the common code.
Control at what points subclassing is allowed, because the basic workflow are defined in the template method you are specifying which methods are allowed to change.
Template pattern:
How to use the base class:
Comments