Jump to content

Inversion of control

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 81.207.141.151 (talk) at 09:09, 10 March 2005. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

Inversion of Control (IOC), or also called Dependency Injection is a Object-oriented programming principle. An object has depedencies, other objects it needs in order to function. Normally either the software or the object itself would make sure that everything was in place in order to function. Either it creates the object it needs internally or it is given to it by another object. IOC inverts this pattern. It checks what an object needs in order to function, and 'injects' those dependencies into the object. A slogan used to descibe this is Don't call us, we'll call you. Dependencies can be resolved by type, by name or any other criteria.

Usually Inversion of Control is done in an Inversion of Control Container. The software requests an object from the container and the contained builds the object and its dependencies. Examples of these containers are PicoContainer, Spring (note that spring is a complete enterprise platform, not just a IOC container) and Avalon.