Tuesday, June 2, 2015

Simple way of understanding IoC and DI

Most of the time it's difficult to distinguish between Inversion Of Control (IoC) and Dependency Injection (DI).  Because they both have inter linked and overlaps with each other.

I will try to put it for you to understand easily and draw a thin line between them.

IoC is the way of  inverting (giving) the control to external entity to create the required object on-demand. Where as the DI is a process of creating and injecting the required objects on-demand to support the IoC.

That means IoC uses DI.   DI can be implemented using setter methods, constructors, etc.

Comments are most welcome...

No comments: