The Rhythm of TDD
TDD cycles are short. Without all the chatter accompanying this chapter’s example, each test-code-refactor cycle takes maybe a few minutes. Increments of code written or changed at each step in the cycle are likewise small.
Once you’ve established a short-cycle rhythm with TDD, it becomes obvious when you’re heading down a rathole. Set a regular time limit of about ten minutes. If you haven’t received any positive feedback (passing tests) in the last ten minutes, discard what you were working on and try again, taking even smaller steps. If you were committing after introducing (and cleaning) each new increment, reverting to the prior increment will be a trivial operation.
Yes, you heard right—throw away costly code. Treat each ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access