|
![]() |
Alan Shalloway.<BR>Look for Jim Trott and my book: <A HREF="http://www.amazon.com/exec/obidos/ASIN/0201715945/ref=ase_electricporkchop/103-0514572-3811868" TARGET=_blank rel="nofollow">Design Patterns Explained</A><BR>Visit our site <A HREF="http://www.netobjectives.com" TARGET=_blank rel="nofollow">Net Objectives</A>.<BR>Visit our <A HREF="http://www.netobjectives.com/dpexplained/index.html" TARGET=_blank rel="nofollow">Design Patterns Explained Community of Practice</A><BR>Check out our <A HREF="http://www.netobjectives.com/xml/xml_cdrom_info.htm" TARGET=_blank rel="nofollow">CDROM based audio training in XML</A>
Alan Shalloway.<BR>Look for Jim Trott and my book: <A HREF="http://www.amazon.com/exec/obidos/ASIN/0201715945/ref=ase_electricporkchop/103-0514572-3811868" TARGET=_blank rel="nofollow">Design Patterns Explained</A><BR>Visit our site <A HREF="http://www.netobjectives.com" TARGET=_blank rel="nofollow">Net Objectives</A>.<BR>Visit our <A HREF="http://www.netobjectives.com/dpexplained/index.html" TARGET=_blank rel="nofollow">Design Patterns Explained Community of Practice</A><BR>Check out our <A HREF="http://www.netobjectives.com/xml/xml_cdrom_info.htm" TARGET=_blank rel="nofollow">CDROM based audio training in XML</A>
Originally posted by Farouk Mohamed1:
Hi
I always have a problem understanding the crucial difference between State and Strategy patterns. When I look at the implementations of both of these patterns i observe no stuctural and coding differences.
State Pattern According to me allows objects to be chosen on run time by the client. So changing objects is possible as and when the client requires a change in the state.
Strategy Pattern aswell allows to change the objects at runtime by the client. So changing objects is possible as and when the client requires a change in the strategy.
As you can see the only difference is only the type of objects Changed (State and Strategy).
Questions on this pattern?
1. Is my way of thinking about State and Strategy Patterns correct?
2. Why to have two different patterns for doing the same work , instead why cant I call it as Runtime object changing pattern which will cover the both the aspects of State and strategy pattern and make developers to imagine abstract situations.
3. If my view is incorrect please explain, your views?
Many Thanks
Farouk
Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Originally posted by Farouk Mohamed1:
Hi Kyle
Thanks for the excellent explanation you did about these two patterns.
Now i understand the crux of it and its importance on the context of usage.
Question.
1. When you say the device hides the implemenation of different strategies of text Compression from the client, and client has no say on i would say the device is playing the role of something like a state machine having different strategies in it.
Do you not think so , i was of the view in both the state and strategy the client has control to change the object on the fly.
Your comments please on
1. Device comparison with state Machine
2. Client's control on the strategy to choose
Many Thanks
Faoruk
Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Don't get me started about those stupid light bulbs. |