How exactly does dependency injection reduce coupling?
Posted
by
dotnetdev
on Stack Overflow
See other posts from Stack Overflow
or by dotnetdev
Published on 2010-12-27T21:27:08Z
Indexed on
2010/12/27
21:54 UTC
Read the original article
Hit count: 241
dependency-injection
Hi,
I've done plenty of reading on Dependency Injection, but I have no idea, how does it actually reduce coupling?
The analogy I have of DI is that all components are registered with a container, so theyre are like in a treasure chest. To get a component, you obviously register it first, but then you would have to interrogate the treasure chest (which is like a layer of indirection). Is this the right analogy? It doesn't make obvious how the "injection" happens, though (how would that fit in with this analogy?).
Thanks
© Stack Overflow or respective owner