Wzorzec Strategy definiuje rodzinę wymiennych algorytmów/zachowań, enkapsuluje każdy z nich i czyni je zamienialnymi w czasie wykonania. Umożliwia dynamiczny wybór algorytmu i unikanie złożonych instrukcji warunkowych, promując elastyczny i rozszerzalny kod.
Co robi wzorzec 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)
