On Wed, 2005-08-31 at 21:19 -0700, Paul Benedict wrote: > Hey guys. > > I have alot of service objects called from Struts, and > each have a good deal of service methods. Service > methods mainly do business logic and talk to DAO > objects. > > Question: > I've taken the approach of service methods having the > responsibility of instantiating DAO objects locally > and using them. Is this correct? Or should I > instantiate all the DAO objects that could ever be > needed in my service constructor, and use them as > instance variables? > > Or is there a better design?
Hi, design is always the matter of the desired functionality, so it's hard to say what is best for you without knowing your business goals. But what can be said for sure, is, that instantiating DAOs locally on each call is a waste of ressources, since each new DAO will probably create a new connection to the db. Having one instance per "service" is generelly better, but you must keep an eye on synchronization and concurrency. regards Leon > > Thanks! > > > > ____________________________________________________ > Start your day with Yahoo! - make it your home page > http://www.yahoo.com/r/hs > > > --------------------------------------------------------------------- > 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]