Discussion about this post

User's avatar
Eric Rizzo's avatar

I might summarize this as "Naive developers will write naive code, TDD or not."

Expand full comment
Bruno Noriller's avatar

I have this in a quick note. It has the "3 laws of TDD" plus this below.

If I remember correctly, this comes from some Uncle Bob lecture:

---

"As tests get more specific, the code becomes more generic."

TDD Transformation List (High to Low Priority)

1 - Null

2 - Null to Constant

3 - Constant to Variable

4 - Add Computation

5 - Split Flow (not yet a switch)

6 - Variable to Array

7 - Array to Container (lists, trees, queues...)

8 - If to While

9 - Recurse (recursion, but careful with tail call optimization)

10 - Iterate (for when recursion isn't a solution)

11 - Assign (changing value of variables)

12 - Add Case (switch, else ifs...)

---

Even in this simple factorial example, this shows. And I keep it because I found it helps when I need to find where/how to generalize the code.

So, while there's a lot of practice involved, there should be other "cheat sheets" one can use to "speed run TDD".

Expand full comment
16 more comments...

No posts