Skip to main content
Dependency Injection
- With DI , objects are given their dependencies at creation time by some third party that coordinates injected object in the system. Objects are not expected to create or obtain their dependencies.
- Depedency injection makes the code and object loosely coupled.
- Tightly couples code is difficult to change, test and maintain.
- Depecency Injection is about, object are provided their depedent object by some third party.
- This third party coordinates the objects in the system.
- The depedencies are not created by the object which need them.
- The depedencies are provided to the object which need them.
- DI binds components of system loosely.
- Two ways DI can be possible
- 1) Using Constructor
- 2) Using setter method