Hacker News new | ask | show | jobs
by nine_k 1252 days ago
Two-step TDD can work if you implement a well-known, stable spec, say, an IP stack.

Such cases are relatively few.

2 comments

There's no such thing as "two-step TDD." That's a cargo cult.

Real TDD is red/green/refactor/repeat in very small steps, writing a handful of lines of code at each step.

I see; I should have quoted it. I was referring to the expression used in the grandparent post.
Right, and in the absence of a well-known stable spec, then it seems to me that TDD (and related) is just a variant on the very old and very discredited "Waterfall Model" [0]

[0] https://en.wikipedia.org/wiki/Waterfall_model

Hardly, if it was a variant of Waterfall you wouldn't have testing mixed in with the development of new code. Waterfall has explicit barriers between the development and test phases which is why those systems usually turn out to be clusterfucks (unless they're small or you have, usually by luck, a correct specification). In real-world Waterfall projects (which I have suffered through, worst was a multi-billion dollar disaster for tax payers, and a multi-billion dollar success for the contractors that we took it over from), testing happens after development which means you have no useful feedback while developing that you are building the wrong thing or building it incorrectly.
I had in mind that Waterfall separates architecture design from detailed design from implementation, and in the above case, the spec being precise and finished certainly means that the top level design (or architecture or whatever) is 100% finished before the TDD development begins.

Hardly a reason to downvote me.

But TDD does not separate architecture design from detailed design from development from testing like Waterfall. It integrates them, or at least enables integrating them. It is literally not Waterfall, which is an idealized (and thus its primary flaw) process predicated on that strong separation that TDD deliberately breaks. TDD is predicated, instead, on the idea that we don't know everything up front. Otherwise we wouldn't need or want to write tests in the middle of development.

As to the downvote, I guess you thought it was me, it was not. But I don't plan to upvote you either.

Fair enough.

For the moment I will assume that I have a misconception that led me astray, and that I should correct in the future once I double check the thinking and the definitions etc., and I'll upvote you now for leading me in a better direction.

> For the moment I will assume that I have a misconception that led me astray

If I understood your posts right, it's the same misconception a few others have had in here:

In TDD, it's not write all tests, then red->green->refactor. It's write one test, red->green->refactor, then write one more test, red->green-refactor, repeat until done.

If it was a variant of the waterfall model then it would just put the testing phase up front and once you developed all your unit tests you start making them pass.
Waterfall TDD would be writing all the tests for the entire project, seeing them all fail, and only then start writing any code for the project.