Strategy

Strategy encapsulates a family of algorithms behind a single interface and swaps them at runtime. It extends by adding a strategy instead of editing an if/switch. In languages with first-class functions, a separate Strategy class collapses into a single function.

March 3, 2024 · 4 min read