Template Method types
March, 2020
Template Method is a behavioral design pattern that defines the skeleton of an algorithm in the superclass but lets subclasses override specific steps of the algorithm without changing its structure:
- abstract
Must be implemented by every subclass. - optional
Already have some default implementation, but still can be overridden if needed. - hook
Optional step with an empty body.
Usually, hooks are placed before and after crucial steps of algorithms, providing subclasses with additional extension points.