On 30.12.2005, at 20:21, Vadim Gritsenko wrote:
Carsten Ziegeler wrote:Gianugo Rabellino wrote:I'm definitely not a fan of constructor injection, exp. when we consider how (way too) often we resorted to inheritance in Cocooncomponents. Now, while interface injection is clearly out of fashion,sticking with Avalon/Excalibur also means that it would be difficultto get around the container (e.g., how do you release components withyour approach? I assume Excalibur still kinda needs that).Yes, Excalibur still needs it - but it's easy. Bascially, you "emulate"the service() method on construction of the object and then you"emulate" the dispose method when destroying the object. Everything our ecm++ needs to know is there. As I said, I've done this in Fortress andwe can use that code in ecm++ as well.And we could implement setter injection with some kind of auto wiring as well. It's not really that harder. But using setters again requires tocode more than using a constructor.I'm with Gianugo on this one - I'd better have setter injection instead of constructor injection.
Maybe this is becoming a bit OT but could you guys give some reasons why?
I personally prefer contructor injection over setter injection because of the clear contract. As soon as the object is instantiated it can be used.
With setter injection you have to have some weird behind the scenes object
life-cycle. cheers -- Torsten
PGP.sig
Description: This is a digitally signed message part
