Could Uncle Bob be mistaken?


Could Uncle Bob be mistaken?

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):

Refactoring to Aggregate Services

Your Host:
Copyright © 2000-2013 by William Sorensen. All rights reserved.