Design pattern to reduce coupling between components, by dynamically injecting into a software component dependencies that it needs to function.
Synonym for Dependency Injection
Dependency injection (DI) is a design pattern for object-oriented programming involving dynamically injecting (inserting) into a software component dependencies (service components) that it needs to function, without needing the dependent component to hard-code a dependency on the service. This reduces coupling between the dependent consumer and the service.
Resources / background questions
If you need a general introduction to DI you should refer to this question: What is dependency injection?
If you need a non-technical introduction you can refer to this question: How to explain Dependency Injection to a 5-year old.
If you would like to understand the relationship between DI and Inversion of Control (IoC), see Inversion of Control < Dependency Injection.
For book recommendations see Dependency Injection book recommendation(s)(dead link).
For general recommendations for writing DI-friendly code without a DI Container, see Dependency Inject (DI) “friendly” library.
If you are wondering why you should use a DI Container instead of Poor Man's DI, see Why do I need an IoC container as opposed to straightforward DI code?
If you are wondering what the Composition Root is, see What is a composition root in the context of Dependency Injection.
For potential downsides of using DI, see What are the downsides to using dependency injection?
Dependency injection and Inversion of Control are closely related. The difference between them is discussed at where-exactly-is-the-difference-between-ioc-and-di.
Also can read basic here : Dependency Injection For Beginner - 1
Related Patterns