- Define a family of algorithms, encapsulate each one, and make them interchangeable.
- Strategy lets the algorithm vary independently from clients that use it.
- Group several algorithms in a single module to provide alternatives.
- Also known as Policy pattern
Where to use ?
- Encapsulate various algorithms to do more or less the same thing.
- Need one of several algorithms dynamically.
- The algorithms are exchangeable and vary independent
- To avoid exposing complex and algorithm-specific structures.
- To reduce multiple conditional statements.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.