Thursday, October 07, 2010

Inversion of control

Inversion of Control, or IoC, is an abstract principle describing an aspect of some software architecture designs in which the flow of control of a system is inverted in comparison to procedural programming.

Dependency injection is the main method to implement Inversion of Control.

Implementation techniques are influenced by the computer language used.

In Java there are six basic techniques to implement Inversion of Control. These are:

1.using a factory pattern
2.using a service locator pattern
3.using a constructor injection
4.using a setter injection
5.using an interface injection
6.using a contextualized lookup

You should not use an Inversion of Control container if you are not familiar with the concepts and if you do not realize the problems they try to solve.

Also, depending on the size and complexity of the project, an IoC container might be overkill. Prefer to use it on medium to large projects.


Inversion of Control and Dependency Injection: Working with Windsor Container


Castle Project offers two Inversion of Control Containers.