Thanks for the comments, guys. The approach of composing singletons
into transients is definitely an interesting one that I will have to
play with at some point. It's good for me to see how others more
experienced at OO than myself handle these kinds of 'problems'.

-Tony

On Dec 3, 4:48 pm, Peter Bell <[EMAIL PROTECTED]> wrote:
> Hi Jaime,
>
> On 12/3/07 4:29 PM, "Jaime Metcher" <[EMAIL PROTECTED]> wrote:
>
> > "A DAO is just a strategy for storing and accessing a large collection, in
> > the same vein as e.g. using a struct and accessing it via a key, or using an
> > array and accessing it via a for loop.  As such it is an implementation
> > detail that most certainly belongs within domain objects.
>
> I'm not sure that I agree with that completely. I happen to compose my DAOs
> within my business objects (so I'm arguing against myself here!), but I
> wouldn't say it is wrong for this to be handled by a service layer -
> especially when you consider remote object calls and the inability to send
> rich objects over the wire. I personally solve that by my UserService.save()
> instantiating a new() user and then User.save()ing, but I don't think
> there's anything wrong with the service layer approach.
>
> > One of the most natural ways to factor this functionality is via the use of
> > singletons.  The fact that it is difficult to inject singletons into domain
> > objects is a design "accident" that has greatly distorted the design of the
> > domain model layer.  If we could specify DI rules for transient objects and
> > be confident they would be applied no matter how the object was
> > instantiated, there would be no anemic domain models."
>
> I think you're going to get anemic domain models for as long as developers
> are having problems "getting" OO and for as long as you have anemic domains
> (some web apps are fundamentally anemic). However, there is nothing
> difficult at all about injecting into transients. ColdSpring has a
> Singleton="false" method, and I wrote LightWire specifically to handle the
> fact that people I respected suggested that while ColdSpring was capable of
> injecting into transients it wasn't really planned for that kind of use (I'm
> not saying you shouldn't use CS for DI into transients - just repeating what
> I was told at the time).
>
> I use LightWire and inject into ALL of my transients (they all have a
> metadata bean, a validation bean and a DAO) and it's been working great for
> me for over a year now on a wide range of projects.
>
> > During the life of this thread a truly voodoo AOP solution was developed
> > that intercepts the constructor and calls Spring to instantiate the
> > transient, with full DI.  Sadly, I don't think this would fly in Cold
> > Fusion - but maybe one of the gurus out there will be inspired to prove me
> > wrong.
>
> Firstly try ColdSpring with singleton=false, and if you have any problems at
> all, there is always LightWire. It was designed for just this use case of
> injecting into all your transients and it takes such a lightweight approach
> to DI I've seen no performance issues at all. At only a few hundred lines of
> code, it's also a really good way to "get" how simple the concepts behind DI
> really is if (like me) you're not smart enough to follow all of Chris
> Scotts' Voodoo that allows ColdSpring to do so much more!
>
> Best Wishes,
> Peter
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CFCDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cfcdev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to