Strategy pattern

E679865

The Strategy pattern is a behavioral design pattern that enables selecting an algorithm’s implementation at runtime by encapsulating each algorithm in a separate interchangeable class.

All labels observed (2)

Label Occurrences
Strategy pattern canonical 5
Strategy interface 1

How this entity was disambiguated

Statements (47)

Predicate Object
instanceOf behavioral design pattern ⓘ
software design pattern ⓘ
alternativeName Policy pattern ⓘ
applicableWhen a class defines many behaviors using conditional statements ⓘ
algorithms contain data that clients should not know about ⓘ
behavior should be selected or changed at runtime ⓘ
different variants of an algorithm are needed ⓘ
many related classes differ only in their behavior ⓘ
belongsTo Gang of Four design patterns ⓘ
category behavioral pattern in object-oriented design ⓘ
consequence allows reuse of algorithms across different contexts ⓘ
eliminates large conditional statements ⓘ
enables dynamic switching of algorithms ⓘ
increases number of objects and classes ⓘ
makes algorithms easier to test in isolation ⓘ
defines family of interchangeable behaviors ⓘ
definesRole ConcreteStrategy implements the Strategy interface ⓘ
Context selects and uses a Strategy ⓘ
Strategy declares an interface common to all supported algorithms ⓘ
describedIn Design Patterns: Elements of Reusable Object-Oriented Software ⓘ
documentedBy Erich Gamma ⓘ
John Vlissides ⓘ
Ralph Johnson ⓘ
Richard Helm ⓘ
enables plug-and-play replacement of algorithms ⓘ
encapsulates algorithm ⓘ
firstPublishedYear 1994 ⓘ
hasIntent define a family of algorithms, encapsulate each one, and make them interchangeable ⓘ
let the algorithm vary independently from clients that use it ⓘ
involves ConcreteStrategy ⓘ
Context ⓘ
Strategy interface ⓘ
promotes composition over inheritance ⓘ
open-closed principle ⓘ
single responsibility principle ⓘ
reduces conditional logic for algorithm selection ⓘ
relatedTo Decorator pattern ⓘ
linked to: Decorator

State pattern ⓘ
Template Method pattern ⓘ
linked to: Template Method
separates algorithm implementation from its usage ⓘ
supports runtime selection of algorithm ⓘ
unit testing of algorithms independently of context ⓘ
typicalImplementationLanguage object-oriented programming languages ⓘ
usedFor compression algorithm selection ⓘ
payment method selection in e-commerce ⓘ
routing or pathfinding strategy selection ⓘ
sorting algorithm selection ⓘ

How these facts were elicited

Referenced by (6)

Full triples — surface form annotated when it differs from this entity's canonical label.

Factory Method → relatedTo → Strategy pattern ⓘ
Bridge → relatedTo → Strategy pattern ⓘ
Template Method → relatedTo → Strategy pattern ⓘ
ConcreteState → relatedConcept → Strategy pattern ⓘ
Strategy (design pattern) → hasParticipant → Strategy interface ⓘ
linked to: Strategy pattern
Gang of Four design pattern → hasExample → Strategy pattern ⓘ