Template method pattern

Subclasses can (but are not required to) customize the operation by overriding the hook methods.

The intent of the template method is to define the overall structure of the operation, while allowing subclasses to refine, or redefine, certain steps.

Through inheritance, the template method in the base class starts to execute.

In the above UML class diagram, the AbstractClass defines a templateMethod() operation that defines the skeleton (template) of a behavior by The template method is used in frameworks, where each implements the invariant parts of a domain's architecture, while providing hook methods for customization.

Provided that hand-written customizations are confined to a subclass, the code generator can be run again without risk of over-writing these modifications.

A sample UML class diagram for the Template Method design pattern. [ 4 ]
Template Method in LePUS3 . [ 5 ]