Dependency Injection

| 0 Comments

Jeremy D. Miller writes about The Dependency Injection Pattern; or what I've tended to call "Parameterise from above". He covers the various ways you can inject a dependency into a class rather than having the knowledge of the dependency hard wired into the class itself. I tend to favour the constructor injection pattern myself; it's all about breaking concrete coupling with interfaces and then allowing the creator of the object to specify the concrete type used by the object.

As Jeremy says, it's not just for testing; it leads to much more flexible software. It's worth following the link from Jeremy's post to Martin Fowler's "Inversion Of Control and the Dependency Injection pattern" as this is definitive coverage of the technique.

Leave a comment

About this Entry

I don't think I've ever been disagreed with in Japanese before was the previous entry in this blog.

Walking Managed Stacks with the Profiling API in v2.0 of the CLR is the next entry in this blog.

I usually write about C++ development on Windows platforms, but I often ramble on about other less technical stuff...

Find recent content on the main index or look in the archives to find all content.

I have other blogs...

Subscribe to feed The Server Framework - high performance server development
Subscribe to feed Lock Explorer - deadlock detection and multi-threaded performance tools
Subscribe to feed l'Hexapod - embedded electronics and robotics
Subscribe to feed MegèveSki - skiing