Skip to Content.
Sympa Menu

patterns-discussion - RE: [patterns-discussion] Are strategy classes stateful?

patterns-discussion AT lists.cs.illinois.edu

Subject: General talk about software patterns

List archive

RE: [patterns-discussion] Are strategy classes stateful?


Chronological Thread 
  • From: Nikolay Atanasov <nikolay_a AT yahoo.com>
  • To: "Donaldson, John \(GEO\)" <John.M.Donaldson AT hp.com>, patterns-discussion AT cs.uiuc.edu
  • Cc:
  • Subject: RE: [patterns-discussion] Are strategy classes stateful?
  • Date: Sun, 23 Apr 2006 03:02:27 -0700 (PDT)
  • Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=JbEzd1AyRHBZjbUMCpj0KczbKxtVCtSOLd4H8VrZKrqHCWk8Foi1ThvVAAX6TnzRB+chcRNq2v3IVbItjDPFRm+43ATTsBqLog4amTfzohwmUGQIwRC1vdS7Cg+yz8djTQMScSPsLD0M0VGK6jS4s2CZ2ZrWGR+v8rV0AjCcyHw= ;
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/patterns-discussion>
  • List-id: General talk about software patterns <patterns-discussion.cs.uiuc.edu>

Thank you very much for the explanation.
I have a design problem about my current task and I’m
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. Let’s 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)"
<John.M.Donaldson AT hp.com>
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:
> patterns-discussion-bounces AT cs.uiuc.edu
> [mailto:patterns-discussion-bounces AT cs.uiuc.edu]
> On
> Behalf Of Nikolay
> Atanasov
> Sent: Friday, April 21, 2006 12:47 PM
> To:
> patterns-discussion AT cs.uiuc.edu
> 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
> patterns-discussion AT cs.uiuc.edu
>
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





Archive powered by MHonArc 2.6.16.

Top of Page