With all the discussions of software craftsmanship and SOLID principles lately, I’d like to list the guidelines (not absolute rules!) I find most useful. These are listed in order of importance, highest to lowest.
Key Principles and Practices of Software Development
Frequent Anti-patterns of Software Development
Remember that the right answer is often “it depends.” Almost everything is a trade-off. Use your own judgment. Think!
Thanks to everyone who reviewed my initial draft, and to Robert ("Uncle Bob") Martin for inspiration.
Comments are welcome.
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):
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.