How do you exactly define IoC (Inversion of Control) vis a vis DI (Dependency Injection)?
Well, as my first attempt at defining IoC and DI, I made the following statement.
IoC is the concept and DI is the way of implementing that. Pretty neat, huh? But how do I go explaining this to anybody in greater depth?
Now, it seems I do have an answer, according to the book Spring In Action:
“IoC aims to offer a simpler mechanism for provisioning component dependencies (often referred to as an object’s collaborators) and managing these dependencies throughout their lifecycles.”
It further states that “IoC can be decomposed into two subtypes: Dependency Injection and Dependency Lookup.”
Now drilling down further, DL (Dependency Lookup) allows acquisition of a reference to a dependency, whereas in DI, the IoC container itself is injecting or providing those dependencies. One can draw an inference that the former scenario is allowing you to control how and when to acquire the dependency and in the second case the container is having the control over the dependency lifecycle.
So, the statement I made above is validated upto a certain extent.
Any further thoughts/comments on this would be certainly welcome.