Template Method (cont’d)
Consequences
- reuse of code
- define invariant behavior
- inverted control flow
- Hollywood principle: “Don’t call us we’ll call you”
Implementation
- minimize the number of primitive operations: “design by primitives”
Java
- primitive operations declared as protected
- when not called by clients using the class
- primitive operations declared as final
- disallow changes to template methods in subclasses