Em Thu, 20 Nov 2008 14:16:33 -0300, Jonathan Barker <[EMAIL PROTECTED]> escreveu:

Ah, I had to jump in.

Everybody is invited!

I like using business services that keep data access code out of my pages. That part feels good.

So do I! :)

Unfortunately, that often means that a findAll() in the DAO has a
corresponding findAll() in the service and that just feels silly.

Mantainability has downsides . . . :)

As a result, I tend to use services for "complicated" stuff that involves
multiple steps or DAO's, and do direct DAO calls from pages for the simpler stuff. Sometimes that means that I'll be injecting services, and the DAO's that the services use into my pages. That also feels silly.

My approach (and the general 3-tier too) is to have pages and any user interface code always using controllers, never using DAOs directly.

So then I consider the statement that DAO's have become an anti-pattern. It makes sense when you consider the redundant findAll()'s that result from separating data access and business services. On the other hand, it doesn't feel good cluttering business services with HQL, SQL, or whatever.

That's one of the reasons I wrote the Ars Machina Generic DAO, Generic DAO-Hibernate and Generic Controller: all the common methods (findAll, findById, save, update, delete, findByExample, etc) are already written. I don't have to rewrite them for every entity class.

To really muck it up, I've got DAO's that extend a generic base DAO. That's fine until the class hierarchy gets a few levels deep and now I'm writing
DAO's for Person, Customer, and Employee.

That's what I want to provide default service implementations in Tapestry-IoC: not having to implement trivial DAOs and controller implementations, just the ones that have methods that my generic DAO and generic controller don't have, and still use the whole "user inteface classes never use DAOs directly" mantra.

If anyone figures out the "One True Way", let me know!  In the meantime,
I'll settle for keeping Session out of my pages.

My own "one true way" was described in this message. :) Comments are invited! ;)

--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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

Reply via email to