Thank you very much for the explanation. I have a design problem about my current task and Im not sure whether some classes are strategies. I have to implement the ValueListHandler (J2EE) pattern. The pattern is connected with EJB server but in my case there is not application server and I must implement something slighting the same. The aim is to have a class that caches a result query and returns a page of objects on request. There are at least 3 implementation of it: The first: all instances are retrieved at once; they are cached in a list and on page request the part of the list is returned. The second: first only instances ID are retrieved and are cached. On page request the implementation retrieves the instances by their ID. The third: nothing is caches. On page request the implementation uses a database feature to get only a part of result set. So the current design is: The ValueListHandler class is injected by any of third implementations. Lets call the implementations at the moment (maybe Caching strategy is better??): RetrieveAll, RetrieveID and RetrieveByRepeateQuery. Every implementation is injected by a class that makes request to database. There are different implementations of this class. One uses hibernate to gets the records, other JDBC calls and so on. My questions are: The RetrieveAll, RetrieveID are stateful because the have cache (first keep the whole records, the second their ids.). The RetrieveByRepeateQuery is stateless because it receives the query and just repeated it. Are these classes strategies? And the last question: is this design is good and how can be improved?
Nikolay --- "Donaldson, John (GEO)" <[EMAIL PROTECTED]> wrote: > Nikolay, > > if you consider one of the reasons you might want to > apply > the Strategy pattern - complex conditional logic - > then I would > expect not much state in resulting > strategy/strategies. > > But I can't think why I would say strictly "no > state, or else > it's not strategy". > > For example, you might want to inject the parts of > the context > on which the strategy operates when you construct > the concrete > strategy instead of doing when you invoke the > strategy itself. > > John D. > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Nikolay > Atanasov > Sent: Friday, April 21, 2006 12:47 PM > To: [email protected] > Subject: [patterns-discussion] Are strategy classes > stateful? > > To All! > > Hello > > I have a question about strategy pattern. Can > strategy classes be > stateful or they are generally stateless? > > Nikolay > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam > protection around > http://mail.yahoo.com > > _______________________________________________ > patterns-discussion mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/patterns-discussion > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com _______________________________________________ patterns-discussion mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/patterns-discussion
