Search code examples
design-patternsstrategy-patternstate-pattern

Strategy Design pattern vs State Design pattern


I was reading through this link about the state pattern. Is it looks like strategy pattern? What is the exact difference between these two patterns?


Solution

  • The difference between State and Strategy is in the intent. With Strategy, the choice of algorithm is fairly stable. With State, a change in the state of the “context” object causes it to select from its “palette” of Strategy objects.

    See http://sourcemaking.com/design_patterns/state