39 karma · joined June 19, 2010
However, if you study that image, you might come to the same insight that I (on my bike ride) came to; and that the english comments never helped me with.
In 2006 Ron Jeffries wrote four blogs about solving Sudoku in Ruby with TDD. His blogging effort ended before he completed the solution. I think he got interested in something else and left the whole thing hanging.
That same year Peter Norvig wrote a Sudoku solver in Python using a constraint based approach. You can see their respective documents here. https://ronjeffries.com/categories/sudoku/… https://norvig.com/sudoku.html
The anti-TDD lobby, at the time, hailed the two documents as proof that TDD didn't work. Ha Ha, Nya Nya Boo Boo.
I was aware of this silliness, but never bothered to study it. I had better things to do. Until March of 2020. Then I thought I'd use Sudoku as a case study for Episode 62 in http://cleancoders.com.
I had not read either of the previous documents and decided to maintain that ignorance while writing the solver in Clojure using TDD. It turned out to be a rather trivial problem to solve. You can see my solution in http://github.com/unclebob/sudoku
I don't know why Ron stopped blogging his Sudoku solver in 2006; but he picked it up again in 2024 and has written much more about it.
The trick I used to solve Sudoku with TDD was to consider the degenerate cases. Sudoku is usually a 3x3x3x3 grid. Let's call this a rank-3 problem. I started with a rank 1 problem which is trivial to solve. Then I moved on to a rank 2 problem which was relatively simple to solve; but was also very close to a general solution. After that I could solve rank N problems.
The TDD strategy of starting with the most degenerate case (rank 1) and then gradually adding complexity may not have been well known in 2006. TDD was pretty new back then. If you explore Ron's first four blogs you can see that he briefly considered rank 2 but opted to go straight into the rank 3 case. The sheer number of variables for each test (81) may have played a role in his loss of interest. In my case (rank 2) I had far fewer variables to deal with.
What you are referring to is a statement I frequently make -- 100% coverage is the goal. It's an asymptotic goal, but it's still the goal. No lesser goal makes any sense.
I also want programmers to be able to use those tools well.
Finally, I look at a lot of crap code written by programmers who throw all their disciplines away because of schedule pressure or other factors. For the sake of going fast they throw away everything that might allow them go actually go fast.
So if a change to your production code causes large changes to your test code, then one, or the other, or both are poorly designed. You have neglected the design. You have allowed couplings to proliferate.
The reasons to not to TDD are:
1. You don't care about the quality of your product. 2. You don't care about the quality of your code. 3. You don't care if there are any bugs. 4. You don't care if the team slows down month after month. 5. You don't care if the project is late. 6. You don't care if the project fails.
If you _do_ care about any of these things; then you should be using a unit testing discipline that guarantees that every line of production code is covered, and checked, by automated unit tests.
Oh, and make sure you know what TDD is. TDD is NOT:
1. Writing all your tests before you write any code. 2. Slow. 3. Too Low level.
If you think TDD is one or more of the above, then you need to do some more research.
Honestly, the year is 2015, and people _still_ resist the one discipline that can actually make a project come in on time, with high quality, and good structure.
That is the SRP.
Example: A class that analyzes a data stream and prints a report. The data analysis will interest one group of people. The format of the report will interest another, different, group. The first group will ask for changes to the algorithms. The second will ask for changes to the format. The principle says to separate those two concerns.
This goes all the way back to David Parnas and the separation of concerns. His papers that describe it are freely available on the web. I suggest that they be studied, because they are full of wisdom and insight.
In one post Robin2 described the course as OO, in another he described it as "C++". Those are two different courses so I'm not sure which it really was. However, back in those days we always did a brief lecture on TDD, as well as several other disciplines such as pairing, refactoring, etc. I was not at the class in question so I cannot comment on precisely what happened; but in general we tried to cover the bases of the various agile disciplines as part of any class we taught. Our customers knew this, and understood the implications. Object Mentor was, after all, the first and foremost of the Agile Transition companies. So all our courses had that flavor.
In light of that, your contention that teaching TDD is "very far from the principles of being agile" is somewhat misguided. Quite to the contrary, to disregard processes and tools is what would be far from agile.
Live long and prosper.
Now, if you'd like to know who I am, I'll be glad to tell you. I've been writing code since 1970. I started on PDP/8s and PDP/11s. I have written BAL, COBOL, Fortran, PL/1, C, C++, Java, C#, Ruby, Python, Clojure, and a bunch of other language I can't remember. I spent many years writing embedded software in 8080 assembler, to control telecommunications micr-controllers. I spent a year and a half working at Rational with Grady Booch on the first two releases of Rose (for my sins). I have written five books on software development and have edited two more. I called the meeting that founded the Agile movement, and served as the first chairman of the Agile Alliance. I was the editor-in-chief of the C++ Report for three years. I am the creator of cleancoders.com, which offers software development video training. Nowadays I spend my time speaking, teaching, making videos, writing blogs, and writing Clojure and Java code.
Is there anything else you'd like to know?
(BTW, the term "uber-hacker" is not mine, and is incorrect. I shall endeavor to get that removed.)
In any case, --- what does this have to do with the article in the title line? It seems odd to be talking about something my son did nearly a decade ago in response to an article I wrote today?
As for Micah, my son, he runs a very successful software development company of 60 or so developers who specialize in extremely high quality software. He maintains very high standards for the developers who work for him. Every one of them practices TDD as well as many other practices that we've found to be beneficial. The result has been a steady stream of very satisfied customers and repeat business. Those customers would likely disagree with you about the reliability of his code; and the code of his employees. But then, I don't imagine your comment was based on any actual knowledge of his code. Perhaps it's best not to report on things you haven't seen.