This post puts forward the intriguing argument that TDD is a hill climbing algorithm & therefore subject to getting stuck in a local maximum. That

Software Design: Tidy First?

submited by
Style Pass
2024-07-08 12:00:05

This post puts forward the intriguing argument that TDD is a hill climbing algorithm & therefore subject to getting stuck in a local maximum. That is, according to this argument, there are valid states of code that can’t be reached one test case at a time. (The post uses the clickbait title “TDD Cannot Work”, which is over-reach on the author’s part.)

The argument as put forward is full of logical holes, but it points to an interesting question—can we characterize kinds of problems best approached some other way than TDD? If we could identify such problems up front, we could save time & effort.

I have a statement & a question. Start with the statement. When we say, “TDD is a hill climbing algorithm,” we are making an analogy. As with all analogies, insight flows from the play of “is” and “is not”. TDD kind of is a hill climbing algorithm. TDD is also kind of not a hill climbing algorithm. The ways it’s similar & the ways it’s different may teach us something about TDD (and maybe a little something about hill climbing).

First, the argument is flawed as presented. Just as well say, “Coding the whole algorithm at once is hill climbing. We write one line first & then all the rest of the lines. There are valid program states we cannot reach this way.” This is clearly specious. 

Leave a Comment