Inversion of Control
Inversion of Control (IOC), or also called Dependency Injection is a popular Object-oriented programming principle which inverts the way an object gets it dependencies. Currently it is very popular in the Java programming language world.
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 container builds the object and its dependencies. Examples of these (Java programming language) containers are PicoContainer, Spring (note that spring is a complete enterprise platform, not just a IOC container) and Excalibur.
External links
- Article "Inversion of Control Containers and the Dependency Injection pattern" by Martin Fowler
- Another description of IOC
- Article "Examining the Validity of Inversion of Control" by Sony Mathew
- Article "Inversion of Control Rocks" by Paul Hammant
- Open Source Inversion of Control Containers