Vasiliy Zukanov
Jul 23, 2017 · 1 min read

Tom, your example of A that instantiates B that instantiates C is not dependency injection. Dependency injection is when A, B and C are instantiated in a centralized component called Composition Root.

Proper DI is when a client that needs A receives only A (through constructor, method or field injection), while being completely agnostic of all the internal dependencies of A.

The imaginary situation that you describe is a common confusion about dependency injection. You can see this presentation by Misko Hevery where he specifically addresses this “myth”.

    Vasiliy Zukanov

    Written by

    Software development consultant, freelance developer and blogger at www.techyourchance.com.