Strategy or Template Method?

Strategy and Template Method both let one step of a routine vary: Strategy hands the step in as an object or function (has-a), Template Method leaves it for a subclass to fill in (is-a); a look-alike table, a run-time change and a second varying step show what each costs, and why most teams reach for Strategy first.

By

Updated

Cheat sheet: Strategy or Template Method?
Category
Data Structures
Level
Journeyman
Tags
Composition over Inheritance, OOP, Strategy Pattern, Template Method Pattern