Blog

Article on Dependency Injection

September 29, 2007

Mark Monster has written an excellent article on Dependency Injection in the newest .NET Magazine (it's no MSDN magazine, but hey, its free of charge). Nonetheless, there are two things I want to mention here.

The author says that Loose coupling is mostly used in the context of SOA and web services. I don't agree. I won't deny the fact that this is also important for SOA, I think that Loose coupling comes from Object-oriented programming. A minor detail perhaps, but hey, you know me. I'm just being picky.

The second issue is when he mentions that it's absolutely necessary to have a Dependency Injection container when using Dependency Injection. This made my alarm bells go off. I completely agree when we are talking about medium-sized to larger projects here. But, I consider it to be harmful when used in smaller projects. How do you know when to use it then? As soon as you experience difficulties when not using a DI container.

Personally, I'm using Dependency Injection for a long time now, and I only have had a few projects where I really wanted to use a DI container to make my life a little easier. I believe YAGNI is an important thing in software development. I recently did an investigation on wich DI container we should use in case we need it. Turns out that Castle Windsor is very powerful and very easy to get started (its also used in the article). I didn't consider StructureMap or Spring.NET, but I guess they are equivalent to Castle Windsor.

Wrapping up this post, I want to say kudos to Mark for putting up an article on Dependency Injection. I consider this an important topic (used with or without TDD), and there are not enough developers out there who use this in there day-to-day coding efforts.

If you and your team want to learn more about how to write maintainable unit tests and get the most out of TDD practices, make sure to have look at our trainings and workshops or check out the books section. Feel free to reach out at infonull@nullprincipal-itnull.be.

Profile picture of Jan Van Ryswyck

Jan Van Ryswyck

Thank you for visiting my blog. I’m a professional software developer since Y2K. A blogger since Y2K+5. Provider of training and coaching in XP practices. Curator of the Awesome Talks list. Past organizer of the European Virtual ALT.NET meetings. Thinking and learning about all kinds of technologies since forever.

Comments

About

Thank you for visiting my website. I’m a professional software developer since Y2K. A blogger since Y2K+5. Author of Writing Maintainable Unit Tests. Provider of training and coaching in XP practices. Curator of the Awesome Talks list. Thinking and learning about all kinds of technologies since forever.

Contact information

(+32) 496 38 00 82

infonull@nullprincipal-itnull.be