Geeks With Blogs
Watson Jon Code and ramblings from Watson

I’m working on a presentation for the Baton Rouge .Net User Group in October on DI so I thought I’d go over some of the reasons to move to DI. Here’s my short list:

  • Better design through loose coupling

That’s about it. There are other reasons that I consider side effects of good design:

  • Testability – easier to test components in isolation since their dependencies can be mocked
  • Flexibility – easier to use alternative implementations since you only need to change the registered components

Those are good things but should not be the main design goal. Remember in the 90s when we used to say that it was important to be able to swap out database implementations? Like going from Sql Server to Oracle - how many times did you really do that? Striving for that may have lead to some good designs, but that was not the goal of the exercise. I’m not saying that being database agnostic is a bad thing, just that it should not be your only design criteria.

Turning that around, what if we strived for simplicity in design? How do we keep our objects simple? We’ll talk about that next time.

Posted on Monday, September 21, 2009 9:50 PM IoC | Back to top

Comments on this post: Motivations for Dependency Injection

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Jon Dalberg | Powered by: