Types of dependency injection.

Hi,

I wanted to know some details about difference between setter and constructor based dependency injection(IOC)

I didnt understood the foll things :

1. "setter based IOC is good for object that take optional parameters and objects that need to change their parameters many times during their lifecycles."The object which is referred is the object to be injected ?

2. In the Constructor based IOC "the creater knows about the referenced object".

Providing links or giving simple examples would be appreciated.

Thanks in advance.

[573 byte] By [Hi_i_am_Amita] at [2007-10-2 14:41:37]
# 1

> Hi,

>

> I wanted to know some details about difference

> between setter and constructor based dependency

> injection(IOC)

>

> I didnt understood the foll things :

>

> 1. "setter based IOC is good for object that take

> optional parameters and objects that need to change

> their parameters many times during their lifecycles."

> The object which is referred is the object to be

> be injected ?

Yes, what else would make sense?

> 2. In the Constructor based IOC "the creater knows

> about the referenced object".

Because the referenced object is a parameter in the constructor call.

> Providing links or giving simple examples would be appreciated.

Martin Fowler's IoC article is the best explanation I've ever read:

http://www.martinfowler.com/articles/injection.html

%

duffymoa at 2007-7-13 13:10:49 > top of Java-index,Other Topics,Patterns & OO Design...