Understanding the Concept of Testability: A Worthwhile Remembrance

I was first introduced to XP in 1999. I remember getting into an avid discussion on the XP user group about TDD. I could never remember what it stood for, often calling it “Test-Driven Design” because I recognized that TDD helped people design their code when using it. This was consistent with the first mantra of design patterns, “Design to the behavior of objects.” Focusing on behavior informed design.

I also remember getting some flack for it. People said things like, “tests couldn’t possibly inform design.” My opinion was, and is, that they not only could they, but they should.

I noticed that when I wrote code without attending to how I would test it (which was most of the time), I would say to myself, “Wow. This code is weakly cohesive (or tightly coupled or has lots of redundancy). I wish I had thought about how I was going to test it before I wrote it!”

One day, before writing some code, I had this blinding flash of insight. “Maybe I should test this code before writing it!” I realized that focusing on behavior as defined by tests, would make the code more “testable.”

At that point I realized that “testability” was a code quality that is highly correlated to cohesion, coupling, redundancy, encapsulation, and readability.

-AMAZONPOLLY-ONLYAUDIO-START-
This is Al Shalloway. Visit us at www.netobjectives.com.
-AMAZONPOLLY-ONLYAUDIO-END-

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.