Pattern-ul Strategy definește o familie de algoritmi/comportamente interschimbabili, încapsulează fiecare dintre ei și le face schimbabili la runtime. Vă permite să selectați un algoritm dinamic și să evitați condiții complexe, promovând cod flexibil și extensibil.
Ce face pattern-ul Strategy
STRATEGY → encapsulate INTERCHANGEABLE algorithms/behaviors behind a common interface:
→ define a family of strategies (each implements the same interface)
→ the context uses a strategy via the interface → can SWAP strategies at runtime
→ choose the behavior dynamically without changing the context
→ "compose" behavior instead of hardcoding it (favor composition over conditionals)
