Dependency Injection and Inversion of Control


Inversion of Control (IOC):

• It gives the control to the container to get instance of Object that is known as Inversion of Control.
• IOC is a container, it creates object for you (Application).
• It means there is no need to use new keyword for creating object.


Normally we do tight coupling:


In Inversion of Control loose coupling:


Dependency Injection (DI):

• The way of injecting properties to an object that is known as Dependency Injection
• Dependency injection is a design pattern that implements inversion of control for resolving dependencies.

We have two types of Dependency Injection:
1) Constructore injection (CI)
2) Setter/Getter injection (SI)