On Jun 19, 2010, at 12:05 PM, James Carman wrote:

> On Sat, Jun 19, 2010 at 11:54 AM, Brian Topping <brian.topp...@gmail.com> 
> wrote:
>> The best reason for me to keep a service/business layer talking to the DAO 
>> is to provide a clean transactional boundary.  Then, all I have to do is add 
>> a Spring @Transactional annotation to the method and I'm fully atomic.
>> 
>> If my view logic is calling a half dozen DAO methods to effect an update, 
>> there's no way to have a single method demarcate the transaction.  Without a 
>> single method, no use of @Transactional, and I have to maintain complex 
>> transactional code by hand.  This is way more error prone and complex than 
>> taking (what are admittedly attractive) shortcuts to remove the service 
>> layer.
>> 
> 
> You can also annotate your Wicket pages/components methods with the
> @Transactional annotation if you use the AspectJ compiler.  They have
> to be public or protected in order for the compiler to pick them up
> and weave them I believe.  No big deal, in practice, really.

Sure, but AspectJ can be a machine gun in the hands of babes.  I try to avoid 
requiring team members be that qualified just to work on basic code.  Because 
once something like AspectJ is in the source base, it starts getting used, and 
before you know it, you have to start making solid experience with this new 
esoterica a hiring requirement.  Too expensive.

> 
>> As a bonus, with well-defined service layer interfaces, I can easily 
>> generate SOAP or REST interfaces and expose them to other fat clients like 
>> mobile devices in the future.
>> 
> 
> Agreed, but having one method that merely delegates to another is just
> plain silly, IMHO.  You'd probably generate custom services that are
> tailored to the different view implementations so that you can
> aggregate things correctly for optimization purposes.

It's a pattern, and sticking with one pattern is very smart.  Especially 
because very few screens in a reasonably valuable application are only going to 
call a single DAO method.  It happens, but I'd question the value of the app at 
that point, and whether it needs transactions at all.  In that case, you are 
right, kill the service layer.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to