Start The World's Best Introduction to TDD... free!

Dependency Inversion Principle (DIP) Comments

I wish that I could take credit for this article, but I can’t. Instead, I have to credit two people: Lasse Koskela and Miško Hevery. I credit Lasse for writing the manuscript that led me to Miško’s article. Look for Lasse’s upcoming book Unit Testing in Java at Manning Publications’ site. Let me summarize Miško’s article here, then you can read the details at his blog.

Why would I simply summarize someone else’s article on this site? Isn’t that dishonest? Not in this case: Miško wrote essentially the same thing that I say over and over again in my own articles and in my training classes. I consider it unfortunate that he and I have never met nor worked together. We really should. You should read his stuff.

So… 10 ways to kill your design.

  1. Instantiate Services wherever the hell you want.
  2. Grab what you want when you want it.
  3. Do real work in your constructors.
  4. Make state easily changed by clients.
  5. Embrace singletons.
  6. Make methods static. (Admittedly, this is more of a problem in Java/C# than Ruby/Python.)
  7. Inherit implementation.
  8. Reimplement polymorphism.
  9. Mix Services and Values.
  10. Keep conjunctions in your variable, method and class names.

Read more about the problems that these “techniques” cause.

Comments