Dependency Injection and .NET
Loose Coupling
When reading about software design, one will obviously meet the magic words loose coupling. This rather abstract concept is often considered as a metric for code quality and testability.
Besides the pure theoretical speculations, there are many significant works, which light up some practical aspects of the loose coupling concept. One should read the Inversion of Control Containers and the Dependency Injection pattern by Martin Fowler 'cause his work gives some great ideas about the dependency breaking problem.
.NET and Inversion of Control
What are the ways to break the dependency in .NET in elegant&efficient manner?
- Implementing a form of Dependency Injection from scratch.
- Using artifacts from the System.ComponentModel namespace to create lightweight containers . This form of implementation corresponds to the Service Locator pattern
- Using third partry like Spring.NET. It supports different forms of Dependency Injection
However the right aproach should be evaluated in a particular context. The impact over the code testability (the practical aspect) should be evaluated for example.
No comments:
Post a Comment