Interchange is a very general principle applicable in many areas. Dependency inversion is a special form of decoupling where you separate the higher levels of your system from the lower levels, dividing them into libraries and using interfaces. This allows you to replace parts of the lower level of your system without major rework.
For example, instead of parts of a higher level system that create specific instances of lower level classes, an IoC container can be used to decouple objects created.
Inversion of control is a design principle used by framework libraries that allow the framework to regain some control over the application. Ie, the window infrastructure can return to application code when certain user interface events occur. Martin Fowler uses the term โHollywood principle,โ as in โDon't Call Us,โ we'll call you. Decoupling is an important part of control inversion.
But what does an IoC container have for inversion of control? To quote Martin Fowler :
Management inversion is too general a term, and therefore people find it confusing. As a result, with a lot of discussion with various IoC advocates, we settled on the name Dependency Injection.
(Note that Martin Fowler talks about dependency injection, not dependency inversion.)
An IoC container helps inject dependency injection, and perhaps the best term would be a dependency injection container. However, the IoC container name seems to adhere. Dependency injection is an important component of dependency inversion, but the use of IoC containers for dependency injection can be confusing because management inversion is a broader and more general principle.
You indicate that the naming is not very consistent, but this should not be a big surprise, as these terms were independently invented and used, although they overlap.
Martin Liversage Oct 12 '10 at 7:59 2010-10-12 07:59
source share