On 11/11/06, Danny Angus <[EMAIL PROTECTED]> wrote:
On 11/11/06, Serge Knystautas <[EMAIL PROTECTED]> wrote:

> Yeah, I'm biased, but I like think this is part of the advantages of
> just dependency injection.

I'm still waiting for someone to give a sensible DI example that would
show how we deal with the fact that there can be an unlimited number
of unknown dependancies.

Service location allows the consumer of the services to look them up
as needed, DI requires that the container be made aware of the
dependance and invoke some mechanism to inject an instance which
satisfies it.

In what way is injection preferable to lookup?

I think we're considering different scenarios since in my ears, your
points support my view.  When I hear unlimited number of unknown
dependencies, that rules out service lookup since it's impossible to
come up with an unlimited number of unknown names for the lookups.
It's all explicit and clear.  It makes a huge ugly XML, but it's much
more rigorous and scales better IMHO.

I haven't used attributes to define DI, but my first reaction is to
not like it since to me it seems that I would have to recompile my
Java classes to change the dependency relationship in some cases.
Actually, studying your example, it seems like it's just removing some
verbosity that I haven't had to deal with with Spring since it excels
at sensible defaults.

--
Serge Knystautas
Lokitech >> software . strategy . design >> http://www.lokitech.com
p. 301.656.5501
e. [EMAIL PROTECTED]

Reply via email to