The basic idea of the Dependency Injection is to have a separate object, an assembler, that populates a field in the lister class with an appropriate implementation for the finder interface.

The core principal of the pattern is to separate behavior from dependency resolution.

There are many frameworks to help implement Dependency Injection.

In JAVA:

a. Spring Framework
In Spring Framework, Dependency Injection (DI) design pattern exits in both major flavors:
Setter Injection and Constructor Injection

b. Google's guice
Guice (pronounced 'juice') is a lightweight dependency injection framework for Java 5 and above. It provides constructor injection.

c. PicoContainer. The framework most important feature is its ability to instantiate arbitrary objects. This is done through its API, which is similar to a hash table. You can put java.lang.Class objects in and get object instances back

In .NET

a. The Unity Application Block aka Unity. Unity is a lightweight, extensible dependency injection container that supports constructor injection, property injection, and method call injection. You can use it with Enterprise Library to generate both Enterprise Library objects and your own custom business objects.

b. StructureMap is a Dependency Injection / Inversion of Control tool for .Net that can be used to improve the architectural qualities of an object oriented system by reducing the mechanical costs of good design techniques. StructureMap can enable looser coupling between classes and their dependencies, improve the testability of a class structure, and provide generic flexibility mechanisms.


More information:

Inversion of Control Containers and the Dependency Injection pattern







Answers and Comments