• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

About Strategy Pattern

 
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends
I have gone through its definition on wikipedia there they have shown one diagram with interface labeled as Strategy.With that i understood that each class which implements that interface is a strategy.So we can say that Strategy Pattern defines set of algorithms(set of strategies), encapsulate each algorithm as an object(strategy object) and make them interchangeable.

but i got confused when i read this

More specifically, a Strategy is an object that is passed into an algorithm and to which the algorithm makes polymorphic method calls - with the intention to make the details of how the algorithm works configurable from the outside.





Can some one please clarify me the Strategy Pattern with respect to the above definitions?
Thanks for reading this
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What confused you was a technical description of an implementation, or in other words, how the pattern can be implemented. Take note that design documentation of a design pattern and a techincal description of an implementation (or runtime behavior) are different things.

If you are genuinely interested in learning about design patterns, then I suggest that you purchase:

Design Patterns: Elements of Reusable Object-Oriented Software (Addison-Wesley Professional Computing Series) by Erich Gamma, Richard Helm, Ralph Johnson, and John M. Vlissides

There is a huge difference between the information you find on web pages and information in a well-written book. Don't cheat yourself, go buy a computer book today!
[ September 24, 2008: Message edited by: James Clark ]
 
raj malhotra
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi James ,
thanks for reply.I have already bought one book -'Head First design Patterns' to start with.But given above two definition - first is mentioned in the book and other is defined by one of javaranch guru.So i wanted to clarify in this forum.Yes i am planning to buy that book in future.Hope my planning is correct to first start with Head First and then dive into that big book.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess you could say that a Strategy is a low level algorithm that can be used to customize how exactly a higher level algorithm works.

Does that help?
 
raj malhotra
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ilja
Yes that reply helps.Thanks for clarifying me.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic