News for hackers. Stuff that matters.
Re:TDD did not live up to expectations by willvarfar on Thursday June 29, 2017 @11:47AM (#14664189)
No article about TDD, particularly one that shouts out to the respected Ron Jeffries http://ronjeffries.com/, is complete without mentioning the TDD Sudoku Fiasco :)

Ravi has a nice summary: http://ravimohan.blogspot.se/2007/04/learning-from-sudoku-so...

Peter Norvig's old-fashioned approach is excellent counterbalance: http://norvig.com/sudoku.html

Re:TDD did not live up to expectations by nikkettt on Thursday June 29, 2017 @12:10PM (#14664386)
Playing devil's advocate here: I'd say that algorithm design (Which is what a sudoku solver is) is a bad fit for TDD.

However, I'd argue that most problems in commercial coding are of a more engineering/architectural type of nature. Here, outside-in TDD has it's place.

Outside-in TDD can help you tackle problems that seem enormous, and slowly but steadily break them into smaller components.

Re:TDD did not live up to expectations by willvarfar on Thursday June 29, 2017 @12:16PM (#14664445)
I find TDD useless as a way of poking at problems I don't actually know how to solve (as Jeffries found with Sudoku), in the way and slowing down when writing large new systems, and excellent when bug-fixing maintenance. Test Driven Debugging!
Re:TDD did not live up to expectations by bluGill on Friday June 30, 2017 @11:30AM (#14671343)
True, but again, most problems I've been given are solved problems I just need to glue the parts together.

I do not design a sorting algorithm from scratch (without consulting any of the literature on writing sort) - I could but the result would probably be a variation of bubble sort. However I stand on the shoulders of giants. That means I already know bucket sort, quick sort, insertion sort, bogo sort (and several more that were covered in CS203). I have never encountered a situation in the real world where calling whatever sort is built into my language is not good enough.

Most problems are variations of take some data, do a little math, and [save for latter use, present to the user, or change some physical control]

Re:TDD did not live up to expectations by gmac on Thursday June 29, 2017 @12:47PM (#14664719)
In a similar vein, I've found it super-helpful when refactoring. It gives you extra confidence that your refactoring isn't gradually breaking important stuff.
Re:TDD did not live up to expectations by eropple on Thursday June 29, 2017 @12:24PM (#14664524)
You can't do TDD when "bug-fixing maintenance". It's a contradiction in terms.
Re:TDD did not live up to expectations by willvarfar on Thursday June 29, 2017 @12:30PM (#14664561)
Curious. How so?

Get a bug report.

Write a unit test that reproduces the bug.

Fix the bug.

The unit test now passes.

Check it in. Now its part of your growing regression suite.

How is this not "test driven"?

Re:TDD did not live up to expectations by Jach on Thursday June 29, 2017 @02:58PM (#14665959)
Where's the design? (To me TDD was always championed to help specifically with Design as much as the vague Development. When using the vague Development too loosely you run into a recursive problem because writing tests is itself development so do you use TDD for your tests?)

Depending on how seriously you take the step of writing a unit test that reproduces the bug, you may be forced to refactor quite a lot of code to get that buggy section under test. Writing the test first can help guide your refactoring to avoid mocking the runtime world. But you're not designing anything, and it was all driven by the bug report.

Re:TDD did not live up to expectations by bluGill on Friday June 30, 2017 @11:08AM (#14671198)
If you are that strict on your definition, yes you cannot TDD when fixing a bug. However all TDD advocates will tell you to write the test for the bug before fixing it. If the code was designed with TDD you will not have to refactor the code to write the test (though the test might be much bigger than it would need to be if the code was designed different). You seem to be describing working with legacy code though, not which is a different situation from TDD.
Re:TDD did not live up to expectations by eropple on Thursday June 29, 2017 @02:44PM (#14665844)
Test-driven development refers specifically to building tests before implementations such that the impressions of the tests (which are communicating the external intent of whatever you're working on) are not colored by the particulars of an implementation. The tests you are writing are necessarily colored by the implementation you're fixing. This isn't bad (though I'd say it's less effective for most programming tasks than TDD), but it isn't TDD.
Re:TDD did not live up to expectations by Cephlin on Thursday June 29, 2017 @11:49AM (#14664210)
Re:TDD did not live up to expectations by hota_mazi on Thursday June 29, 2017 @12:25PM (#14664527)
I don't find most of the Uncle Bob writes to be clever, and especially when he writes about TDD.

He's just too dogmatic to be credible to anyone working in the industry (and make no mistake, Uncle Bob knows absolutely nothing of the software industry in the 21st century).

His writings are only here to promote himself, his books and his consultancy. That's it.

Re:TDD did not live up to expectations by neuromantik8086 on Thursday June 29, 2017 @12:55PM (#14664794)
I weakly agree with this statement. While I think there is merit to TDD under some circumstances (that others have described quite elegantly and succinctly elsewhere in the this thread), my main takeaway from the Clean Coder was that if I ever got super burned out I should just start a consultancy.

[addition]: I also find it weird how the Clean Coder seemed to encourage burnout by prescribing that you use your off-hours to hone your craft. While I agree that software engineering should be treated more like a craft (in particular, I'm thinking of the apprenticeship and craftsman ship culture that is prevalent in Germany / possibly other former Hansa areas), I don't think that it's reasonable to assume that people should sacrifice their personal time for it. I understand that sometimes this might be necessary (the proverbial night class to get up to speed with some new domain of knowledge), but his implying that surgeons constantly practice surgery during their off-hours (and really, short of illegally exhuming bodies, how would they do this?) seemed a bit of a naive and unrealistic ideal.

Re:TDD did not live up to expectations by insulanian on Thursday June 29, 2017 @02:48PM (#14665887)
Thank you for saying this loud.
Re:TDD did not live up to expectations by mjw1007 on Thursday June 29, 2017 @12:57PM (#14664811)
The 'Fiasco' is a bit of an unfair comparison, because Jeffries is deliberately providing a 'stream of consciousness' writeup while Norvig's is a cleaned-up version with false starts removed.

(You can tell Norvig's code worked differently at one point by looking at the return value of assign(), for example.)

Re:TDD did not live up to expectations by willvarfar on Thursday June 29, 2017 @01:17PM (#14664989)
I would be staggered if Norvig's approach ever wasn't constraint propagation and backtracking.

Solving Sudoku is blindingly obvious even to mere mortals with even a iota of exposure to computer science and algorithms.

Re:TDD did not live up to expectations by mjw1007 on Thursday June 29, 2017 @01:23PM (#14665050)
Sure, Norvig knew how to solve the problem from the start.

But that's another reason why the "TDD Sudoku Fiasco" blogpost isn't a terribly useful source of information (or, from another point of view, why it isn't a great way to persuade a TDD afficionado to change their mind).

Re:TDD did not live up to expectations by plinkplonk on Thursday June 29, 2017 @01:50PM (#14665336)
that 3 line post is the most popular blog post I ever wrote.

I got a lot of nasty mail from agile consultants, but it was worth it, heh!

Which reminds me, I haven't blogged in years.

One day I just stopped.

Perhaps it is time to restart.

Re:TDD did not live up to expectations by ajross on Thursday June 29, 2017 @12:42PM (#14664676)
To be fair (and I'm no TDD fan personally), that mess wasn't really the fault of TDD at all. It was that Jeffries was learning how to write a Sudoku solver while he was writing his tests. If he started from Norvig's level of understanding, he surely could have written tests for an equivalently elegant solver quickly and simply.

Learning how to solve a problem by iterative coding (and throwing away the intermediate solutions) is a time-honored tradition that works very well. TDD may be an imperfect vehicle for doing that, but it doesn't really change the calculus.

Re:TDD did not live up to expectations by willvarfar on Thursday June 29, 2017 @01:19PM (#14665012)
The whole thing at the time was 'test driven design' - the idea that by writing tests, you could iterate your way to algorithms that solve problems you couldn't solve by critical up-front thinking.

Test Driven Design fizzled and quietly died just after the Sudoku Fiasco ;)

Re:TDD did not live up to expectations by krmboya on Thursday June 29, 2017 @12:52PM (#14664754)
Well, to me it seems that if you stretch the idea of separation of concerns, you should separate the process finding out what you should do, from the process of how you should do it right.