Dependency Injection
A design technique in which an object receives its collaborators from outside instead of constructing or globally locating them itself.
Dependency Direction
Dependency injection separates object construction from object behavior. A component declares what it needs, while another part of the application decides which concrete implementation supplies that dependency.
Constructor injection makes required dependencies explicit and usually keeps the object usable without a framework-specific global lookup.
What DI Does Not Solve
DI does not automatically produce a modular architecture. A class can still depend on too many services, leak infrastructure concerns or form cyclic dependencies.
It is one implementation technique commonly used with Inversion of Control and the dependency direction discussed in Change-Resilient Architecture with SOLID.
Related Software-Engineering Concepts
- Interface Segregation
- Dependency Inversion
- Hexagonal Architecture