From CSSEMediaWiki
Jump to: navigation, search

I'm still not quite sure if I do understand the difference of the State and Strategy pattern. I added what I think is important to my understand.... --Dom 03:08, 20 August 2008 (UTC)

The difference between strategy and state is the intent. The Strategy pattern is used when the purpose is to provide different functionality, using different algorithms. The State Pattern is used when the propose is to represent the different internal states that the object can have. Doing this using the state pattern has some advantages such as explicitly defining valid states and preventing the object from entering a possibly invalid state. Strategy provides functionality. State stores information. Does that help? -Jason Clutterbuck 23:07, 11 September 2008 (UTC)

As per conversation with Dom the right word here is behaviour. So the State pattern is for capturing behaviour that is state dependent. -Jason Clutterbuck 02:51, 12 September 2008 (UTC)

Personal tools