Book: Dependency Injection in .Net

Dependency Injection in .Net by Mark Seemann

I must say from the beginning, this is definitely one of the best book I’ve read about programming. I found the book written so well that I think Seemann reviewed the text at least a hundred times and fine tuned each phrase to obtain the perfect whole.
The thing I liked the most about the book was that the information was very well structured and presented in a very logical way. The second thing I liked it was the fact that once I started reading, I couldn’t let it off my hand until I read it all. And I like that on a book.
Going through the content, the book is made In Part 1, the author explains what DI is, why it is useful and shows some DI examples: a simple one first, but also a more complex one, because it is the complex and large projects where the DI becomes extremely helpful. Despite being complex, this second example is quite easy to understand because is constructed based on a (kind of) real life discussion between programmers.
Part 2 is all about how to do and how not to do DI. These are presented as patterns (constructor injection, property injection, method injection and ambient context injection) and anti-patterns (control freak, bastard injection, constrained construction and service locator – and I know there is an ongoing discussion here about the service locator being good or evil, but Seemann makes a pretty damn good point about it in the book).
Part 3 goes a step further and, in order to better assimilate the concepts, it shows how you can create your own DI container. This will guide the reader between all the aspects and the problems DI faces and explains how to address issues like object life time, object creation interception, cross cutting concerns, etc. There is also a chapter about object composition when working with some of the most important .Net technologies (ASP.NET, WPF, WCF).
In part 4, each chapter is dedicated to one of the most used DI containers: Castle Windsor, StructureMap, Spring.NET, AutoFac, MEF and Unity. These chapters are not detailed references about the containers, but are there more to give the reader a feel about how using one container or the other might be like.
Now that I showed a little bit what subject the book touches, I must say that I can’t emphasize enough how much I enjoyed the way in which this information was presented: simple, with reminders, with case studies, with well-made arguments.
I strongly recommend this book to every .Net developer, even to those who are already using one of the DI containers available for .Net; they will better understand the concepts and will find about alternatives to the container they are already using. And for those who never used DI before, this is definitely a must read. You will see programming a lot more different after reading it.

2 Comments

  1. Hi there, just became alkert to your blog through Google, and
    found hat iit is truly informative. I am going to warch out for brussels.

    I’ll appreciate if you continue this inn future.
    Many people wiill be benefited from youur writing. Cheers!

Leave a Reply

Your email address will not be published. Required fields are marked *