The Template Method
Intent: We want to abstract out a common theme from different cases that have different implementations of an algorithm.
Example: Often systems/frameworks have a fixed workflow where the steps are always executed in a specific sequence, but the actions taken in each step vary by application context. Template method separates the common workflow from the individual steps it executes/organizes. The template method may also contain common conditionals or other logic that does not vary by implementation.
Figure 20: Template method example diagram.
A Conceptual Diagram
Qualities and Principles: The template method separates a ...
Get The Design Patterns Companion now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.