DEV Community

ruthmoog
ruthmoog

Posted on • Edited on

Book Club: "Test Driven Development: By Example" #9

Chapter 9: Times We're Livin' In

In TDD we don't ask "how do we want to implement X", but "how do we want to test for X".

We utilised the factories in this chapter, so that the Dollar and Franc constructors could be effectively the same - and allow for the implementation to be pushed up to the super class. Having the experience of the refactor on two classes which are essentially the same-but-different along with the transparency from the tests, allowed some experimentation with the size of the steps in each refactor; the design and TDD process here is an example of both being able to work carefully, and work faster.

TDD is a steering process ... There is no right size step, now and forever.

Along the way, the flow of my code change was interrupted by something on the side (we'd been using the constructor instead of the factory in the .times() method). Beck introduces a rule credited to Jim Coplien, to allow one brief interruption but never an interruption to an interruption. Anything else should go on the To Do list.

🔎 View my code-along repo at https://github.com/ruthmoog/test-driven-development-by-example


Book cover Kent Beck's "Test Driven Development: By Example" was released in 2002. The book aims to explain how to use TDD to write quality code that works.

Top comments (0)