I have a great deal of respect for “Uncle” Bob Martin. He’s done a tremendous amount to bring professionalism and craftsmanship to software development. I’ve heard him speak, and he definitely knows more than I do. But in this one small area of programming, I think he’s off-target. Decide for yourselves.
Dependency Injection Inversion (Uncle Bob)
Some of the follow-ups:
Poor use of DI versus need for DI (Jimmy Bogard)
Dependency Injection Inversion Rejection (Davy Brion)
Constructor over-injection anti-pattern (Jeffrey Palermo)
I agree most closely with Jimmy Bogard on this (Davy Brion makes some good points too). In Jeffrey Palermo’s post, I side with Alwin in his comment - why not just pass an interface to the factory?
EDIT: Here’s a nice rebuttal to Jeffrey Palermo’s post that discusses better alternatives to Alwin’s solution:
Rebuttal: Constructor over-injection anti-pattern (Mark Seemann)
EDIT: Another response to Uncle Bob:
Rejecting Dependency Injection Inversion (Ayende)
EDIT: And another related post by Mark Seemann:
Dependency Injection Inversion in .NET
EDIT: Yet another interesting post by Mr. Seemann (I think I’ll pick up his book):
No Comments/Pingbacks for this post yet...
Development Central is the blog of Bill Sorensen, a professional software developer. Much of this will relate to C#, .NET, and OOP in general.
Disclaimer
These postings are provided "AS IS" with no warranties and confer no rights.