Modeli Strategy përcakton një familje të algoritmeve/sjelljedhjeve të zëvendësueshme, i pakon secilën, dhe i bën të shkëmbyeshme në kohën e ekzekutimit. Ai ju lejon të zgjidhni një algoritëm në mënyrë dinamike dhe të shmangni kushtet komplekse, duke promovuar kod fleksibël dhe të zgjerues.
Çfarë bën modeli 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)
