Must Dependency Injection come at the expense of Encapsulation?

Posted by urig on Stack Overflow See other posts from Stack Overflow or by urig
Published on 2009-06-17T06:58:01Z Indexed on 2010/03/24 0:43 UTC
Read the original article Hit count: 414

If I understand correctly, the typical mechanism for Dependency Injection is to inject either through a class' constructor or through a public property (member) of the class.

This exposes the dependency being injected and violates the OOP principle of encapsulation.

Am I correct in identifying this tradeoff? How do you deal with this issue?

Please also see my answer to my own question below.

© Stack Overflow or respective owner

Related posts about dependency-injection

Related posts about inversion-of-control