Hi Mick, I like your implementation od DAO , Can you send me a example for
this? I would like use it.

Fede


----- Original Message -----
From: "Robert Taylor" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Monday, August 25, 2003 3:07 PM
Subject: RE: Is singleton DAO acceptable? -- Best Practices


Mick,

The design pattern doesn't states how DAO's are to be implemented, but
rather what problem they are supposed to solve.

One reason why you might not want a DAO to be a singleton is if you
instantiate
one with an Connection. This might be done to avoid having to pass the
Connection
to each method.

I think your implementation is appropriate. It makes sense performance wise
and it
is also intuitively more OO. Why create a new instance of an object if it
does
not maintain state?

My .02,

robert







> -----Original Message-----
> From: news [mailto:[EMAIL PROTECTED] Behalf Of Mick Wever
> Sent: Sunday, August 24, 2003 12:59 PM
> To: [EMAIL PROTECTED]
> Subject: Is singleton DAO acceptable? -- Best Practices
>
>
> All the DAO examples I've read have DaoFactory classes that always return
> a new DAO instance, and typically the action using it keeps a handle to it
> for that session.
>
> The DAOs that I've created have no state or instance variables, and get
> their connections from a synchronized pool (and always returning the
> connection within the same method call). So, since they are
> multi-threaded, it makes sense to me performance wise it is better
> for the factory to always return a singleton instance of the DAO.
> This single instance of the DAO is shared across all sessions in
> the JVM.
> (Note this is not the traditional usage of singleton where the singleton
> itself is responsible for returning the single instance through a static
> method).
>
> My question is, is this such a good idea? Am I missing or misunderstanding
> something crucial about the DAO Design Pattern?
>
> Mick.
>
> --
> <BR/>
> "We all may have come on different ships, but we’re in the same
> boat now."
> Martin Luther King. Jr.
> <BR/>
>  --- <a
> href=http://www.harryspractice.com.au>www.harryspractice.com.au</a> ---
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to