MΓ³dulo 23 Β· Design Patterns (All 23 GoF) β LecciΓ³n 22 de 23 Β· ~6 min
Template Method
Template Method: base defines the skeleton, subclass fills a step
Problem: several variants share the same overall flow but differ in one or two steps.
PawWalk scenario: a report generator whose run always does header, body, footer. Each report type overrides only body.
The base method calls overridable methods; subclasses override just the varying step. (In Ruby you could also inject a block β but the classic template method is a clean fit when the skeleton is fixed.)