Realsolve Logo
Technologies
 

Dependency Injection

All software systems have dependencies. A network application is dependent on the software libraries which provide the functionality to access the network. A database application is dependent on the libraries needed to access the database. Virtually all systems use files in some way, and are thus dependent on libraries to access the file system.

Dependency injection is a technique used to reduce possible negative impact of dependencies on code that uses them. The basic idea is that the responsibility for obtaining the reference to the dependency�is removed from the code that uses this dependency. Instead, a specially designed framework is used to manage the dependencies on behalf of the application.

Instead of having to find a reference to the dependency, this reference is provided to the application code by the framework.�Resolving�dependencies�thus becomes not a matter for application code, but�a matter for configuration. This makes a system more�easily�configurable, and in particular, makes it easier to test using�test driven development.

A framework which provides this kind of service is known as an Inversion of Control container. The leading IoC container in the market at the moment is probably the Spring Framework