What is Dependency Injection?

Martin Fowler original coined the term in his article, “Inversion of Control Containers and the Dependency Injection pattern”. In it, he explains in great details his approach in creating high cohesive application with weak coupling modules. It’s a design pattern that allows a separate assembler module to inject the implementation into a class. The author derived Dependency Injection from Inversion of Controller for a more specific name for this pattern.

In my simple definition, dependency injection is a concept to move dependency between classes / controls / methods / interfaces by place this dependency in a configuration files (such as xml-based config file).

Before the dependency injection time, developers achieve weak coupling by manually injected dependency in a new class. This new class is responsible for bridging the other two classes. This approach introduces new problem such as, when modifications need to be done in the code, the code will need to be recompiled.

Scott Hanselman has a good list of .Net Containers that can be found here.

Another good read for Dependency Injection term is from Wikipedia.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s