Strategy Pattern

Noun · Development

Definitions

  1. A behavioral design pattern that encapsulates interchangeable algorithms behind a common interface, letting the client switch strategies at runtime. Eliminates large conditional blocks (if/switch on type). In functional languages, achieved by simply passing different functions as arguments.

    In plain English: Making algorithms swappable by hiding them behind a common interface, so you can change behavior without changing code.

    Example: "The sorting component accepts a strategy — pass CompareByDate for chronological order or CompareByRelevance for search results."

Related Terms