Strategy

From CSSEMediaWiki
Revision as of 05:26, 17 August 2008 by Dominic Winkler (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Intent

"Define a family of algorithms, encapsulate each one, and make them interchangeable" [GoF] That means to capture the abstraction in an interface and bury implementation in derived class, so that it lets the algorithm vary independently from clients that use it depending on the context.

When to use it

The strategy pattern is useful for situations where it is necessary to dynamically swap the algorithms used in an application

UML Diagram

Strategy.jpg

Personal tools