dcsimg
did anybody used Strategy pattern?
4 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   devaki_perumal
Posted On:   Wednesday, March 20, 2002 09:44 PM

did anybody used Strategy pattern?.Can u please explain me this pattern with example code
Thanks

Re: did anybody used Strategy pattern?

Posted By:   David_Liu  
Posted On:   Friday, April 5, 2002 06:19 AM

Buy the GOF book. Design Patterns pusblished by Addison Wesley.

Re: did anybody used Strategy pattern?

Posted By:   Anonymous  
Posted On:   Thursday, March 28, 2002 03:12 PM

I use it regularly.

See

http://www.refactoring.com/catalog/replaceTypeCodeWithStateStrategy.html

http://ootips.org/strategy-vs-case.html

Re: did anybody used Strategy pattern?

Posted By:   Paul_Connaughton  
Posted On:   Wednesday, March 27, 2002 03:07 AM

The strategy pattern is often used for defining a family of algorithms identified by a single interface. Each one is encapulated in an implementation and then they are all interchangeable.



One good example of the Strategy pattern is the LayoutManager in AWT/SWING UIs. Here a variety of layout algorithms are provided, each one implementing the LayoutManager interface.



The Gamma book/bible Design Patterns has more examples of the Strategy pattern.

Re: did anybody used Strategy pattern?

Posted By:   Bozidar_Dangubic  
Posted On:   Friday, March 22, 2002 06:14 AM

I used it in one application. I cannot give you the source code because of copyright issues. I used it in the application where data binding was needed, i.e. data from the xml files needed to be mapped to java objects. there are several possibilities on how this can be accomplished. java's answer to this problem is jaxb but jaxb is in the early access release and has a number of shortcomings. there is castor. there is also xslt with java extensions. I used strategy pattern so that I can quickly change the strategy from jaxb to castor to xslt without much change in the code. you basically use strategy pattern when you have altering behaviors and you want or need to have a way to configure a class with one of many behaviors or when you need different variants on the same algorithm.
About | Sitemap | Contact