4 ms·
I'm familiar with TDD, both its strenghts and limitations (http://ravimohan.blogspot.com.ar/2007/04/learning-from-sudoku-solvers.html http://ravimohan.blogspot.
by the_af 12y ago
I'm familiar with TDD, both its strenghts and limitations (http://ravimohan.blogspot.com.ar/2007/04/learning-from-sudoku-solvers.html http://ravimohan.blogspot.com.ar/2007/04/learning-from-sudok..., http://beust.com/weblog/2014/05/11/the-pitfalls-of-test-driven-development/ http://beust.com/weblog/2014/05/11/the-pitfalls-of-test-driv..., etc).
I understand that this kind of testing often works (though I'm less enthused with TDD as a design technique, which is unfortunately what TDD proponents emphasize, and what you seem to be describing here). I'm saying it is too limited. "But software is written and tested this way", you can say. But buggy software is written every day, even with testing, which is why we should strive to improve our testing tools & processes.
To be clear I'm not saying "abandon TDD" (ok, maybe I'm not rooting for TDD in particular, but I'm definitely not saying "abandon unit testing"). What I am saying is "complement it with static typing and more advanced testing techniques, such as property testing."
Finally:
>> it fails to tell apart addition from the constant function 7
> It's not supposed to do that.
Well, in a way it is. Your tests must attempt to detect flawed implementations, even though they cannot prove correctness. I'm sure you can think of cases where an algorithm sometimes seems to return the correct result, but fails in some cases.
- mpweiher 12y agoWell, you're obviously not familiar with TDD, just with silly straw man arguments against it. No, the 4+3=7 test is not supposed force creation of actual addition, the additional tests + design principles do. And I am not saying "but software is written and tested this way". Software is written and (often not) tested in many ways. I am saying that in my practical experience software that is written this way is both much simpler and much more robust than people not familiar with these techniques such as yourselves imagine. Or maybe can imagine. As to architecture, I strongly recommend Henrik Gegenryd's PhD Thesis: "How Designers Work"[1]. By the way, please don't confuse "easy" with "simple" like the second blog post you reference. [1] http://chrisrust.wordpress.com/1998/12/31/how-designers-work-making-sense-of-authentic-cognitive-activity/ http://chrisrust.wordpress.com/1998/12/31/how-designers-work...
- the_af 12y agoPlease do not assume I'm unfamiliar with TDD because I disagree with you. It diminishes your argument. Here you'll find references from big names (Peter Norvig, Joshua Bloch) discussing limitations of TDD as a design process: http://gigamonkeys.wordpress.com/2009/10/05/coders-unit-testing/ http://gigamonkeys.wordpress.com/2009/10/05/coders-unit-test... (read it, it's more balanced than you'd think). Here are some interesting comments from the above: - Bloch: tests are inadequate as documentation. - Norvig: I like TDD but it's inadequate to discover unknown algorithms. (The infamous Sudoku Solver debacle is a particularly painful example of Norvig's claim, and in particular I think Ron Jeffries' attempt at doing TDD was embarrassing. Like the blog says, if I were a TDD proponent, "I'd be pretty strongly tempted to throw Jeffries under the bus") Very few if any of the people mentioned outright dismiss TDD, but they do point out its limitations, which to me are mostly about TDD as a design process. If we go back to TDD as testing, my initial objections apply: it's useful, but it's not enough. More advanced and formal tools, and static typing, are of great help here. Even if you disagree with everything else, you must at least agree with this: computers are about automation. Automating as much as we can, including testing, is a good thing. Writing tests is itself something that can -- in some areas -- be automated, in which case it should be preferred over hand-writing those tests.