Module 27 ยท Design Patterns (All 23 GoF) โ Lesson 22 of 23 ยท ~6 min
Template Method
Base defines the skeleton; subclasses fill in steps
Template Method puts the overall algorithm in a base method that calls smaller steps, letting subclasses override individual steps without changing the sequence. A report generator's run() always does header, then body, then footer โ but each report type supplies its own body().
This one genuinely benefits from inheritance: the base fixes the order; subclasses customize the variable parts.