Strategy
E173620
Strategy is a behavioral design pattern that defines a family of algorithms, encapsulates each one, and makes them interchangeable so that clients can vary their behavior independently from the algorithms they use.
All labels observed (1)
| Label | Occurrences |
|---|---|
| Strategy canonical | 1 |
Statements (49)
| Predicate | Object |
|---|---|
| instanceOf |
behavioral design pattern
ⓘ
design pattern ⓘ software engineering concept ⓘ |
| allows |
runtime selection of algorithm
ⓘ
variation of behavior without modifying client ⓘ |
| alsoKnownAs | Policy pattern ⓘ |
| applicableWhen |
algorithm should be selected at runtime
ⓘ
clients should not know algorithm implementation details ⓘ different variants of an algorithm are needed ⓘ many related classes differ only in behavior ⓘ |
| authorsDescribedBy |
Erich Gamma
ⓘ
John Vlissides ⓘ Ralph Johnson NERFINISHED ⓘ Richard Helm ⓘ |
| belongsToCategory | behavioral pattern ⓘ |
| consequence |
eliminates conditional statements for algorithm choice
ⓘ
increases number of objects and classes ⓘ |
| contextDelegatesTo | Strategy for algorithm execution ⓘ |
| contextHolds | reference to Strategy ⓘ |
| definedIn |
Gang of Four design pattern
ⓘ
surface form:
Gang of Four design patterns
|
| definesInterface | common method for all algorithms ⓘ |
| enables |
switching algorithms at runtime
ⓘ
testing algorithms independently ⓘ |
| encapsulates |
algorithm
ⓘ
behavior ⓘ |
| encourages | loose coupling between client and algorithms ⓘ |
| exampleUseCase |
compression with different algorithms
ⓘ
payment with different payment methods ⓘ routing with different pathfinding algorithms ⓘ sorting with different comparison strategies ⓘ |
| hasIntent |
define a family of algorithms
ⓘ
encapsulate each algorithm ⓘ let clients vary behavior independently from algorithms ⓘ make algorithms interchangeable ⓘ |
| hasRole |
ConcreteStrategy implements algorithm
ⓘ
Context uses a Strategy object ⓘ Strategy declares algorithm interface ⓘ |
| originatesFrom | Design Patterns: Elements of Reusable Object-Oriented Software ⓘ |
| promotes |
composition over inheritance
ⓘ
open-closed principle ⓘ single responsibility principle ⓘ |
| relatedTo |
Decorator
ⓘ
surface form:
Decorator pattern
ConcreteState ⓘ
surface form:
State pattern
Template Method ⓘ
surface form:
Template Method pattern
|
| solvesProblem |
conditional logic for algorithm selection
ⓘ
hard-wired algorithms in client code ⓘ |
| typicalParticipants |
ConcreteStrategy
ⓘ
Context ⓘ Strategy interface ⓘ |
Referenced by (1)
Full triples — surface form annotated when it differs from this entity's canonical label.