What is Template Method, how does it differ from Strategy, and what is a hook method?
Short answer
Template Method: the parent keeps a fixed algorithm skeleton in a final method and subclasses fill in the steps. Strategy: swap the whole algorithm for another object at runtime.
3 points to say:
- A
finalskeleton keeps the order fixed. - A hook is an optional step with a default.
- Strategy swaps the whole algorithm at runtime.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.