THE ATHENA LIBRARY
Design Patterns Field Guide
Noah Bekele field guide
Pattern 2
Strategy
The Strategy pattern replaces a long chain of if statements with a family of interchangeable objects. A PaymentProcessor holds a reference to a PaymentStrategy and simply calls pay(amount).
Each concrete strategy — card, mobile money, bank transfer — implements the same interface. New strategies can be added without modifying the processor.
Strategy is polymorphism made deliberate: behaviour is selected by choosing an object, not by branching on a flag.
Fictional educational sample written for the Athena demo · Page 33 of 184.
50%saved