Le pattern Strategy définit une famille d'algorithmes/comportements interchangeables, encapsule chacun, et les rend interchangeables à l'exécution. Il vous permet de sélectionner un algorithme dynamiquement et d'éviter les conditionnelles complexes, en favorisant un code flexible et extensible.
Ce que fait le pattern 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)
