Vzor Strategy definuje rodinu vzájemně zaměnitelných algoritmů/chování, zapouzdřuje každý z nich a umožňuje jejich výměnu za běhu. Umožňuje vám dynamicky vybrat algoritmus a vyhnout se komplexním podmínkám, čímž podporuje flexibilní a rozšiřitelný kód.
Co vzor Strategy dělá
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)
