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
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
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.
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"?
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.
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]
and: http://blog.cleancoder.com/uncle-bob/2016/11/10/TDD-Doesnt-w...
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.
[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.
(You can tell Norvig's code worked differently at one point by looking at the return value of assign(), for example.)
Solving Sudoku is blindingly obvious even to mere mortals with even a iota of exposure to computer science and algorithms.
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).
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.
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.
Test Driven Design fizzled and quietly died just after the Sudoku Fiasco ;)