Strategy obrazac definira obitelj zamjenjivih algoritama/ponašanja, enkapsulira svaki od njih i čini ih zamjenjivima tijekom izvršavanja. Omogućuje vam dinamički odabir algoritma i izbjegavanje složenih uvjetnih iskaza, što promovira fleksibilan i proširiv kod.
Što Strategy obrazac radi
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)
