Chapter 7. Testable design

 

In this chapter

  • What is testable design?
  • What is untestable design?
  • How to create testable designs

In the preface of Implementation Patterns (Addison Wesley Professional, 2007), Kent Beck compares programming to an American TV show called Jeopardy. In the show the host provides answers and the contestants’ job is to guess which question that answer was for. “A short section at the end of a book.” “What is an epilogue?” “Correct.”

Kent makes the analogy to programming and points out that Java provides answers in the form of its language constructs, and the programmer’s job is to figure out what the questions are and which problems are solved by which language construct. He offers the following example: if the answer is “Declare a field as a set,” the question might be, “How can I tell other programmers that a collection contains no duplicates?”

The same happens with design. Throughout our education and especially the first years of our professional careers, we’re taught solutions. Our senior colleagues show us “the way things are done around here,” and we pick up coding conventions from the code we work with, and sometimes we pick up stuff from books like this. But it’s not enough to know solutions. We also need to learn to identify the problems they solve. That’s why this book includes a catalog of test smells.

7.1. What’s testable design?

7.2. Testability issues

7.3. Guidelines for testable design

7.4. Summary

sitemap