RichardKennaway comments on Coding Rationally - Test Driven Development - Less Wrong

25 Post author: DSimon 01 October 2010 03:20PM

You are viewing a comment permalink. View the original post to see all comments and the full post content.

Comments (82)

You are viewing a single comment's thread. Show more comments above.

Comment author: cousin_it 03 October 2010 09:47:54PM *  5 points [-]

What you're saying is too abstract, I can't understand any of it. What would be the "preconditions and postconditions" for Google Maps? "The tiles must join seamlessly at the edges"? "When the user clicks and drags, all tiles move along with the cursor"? How do you write automated tests for such things?

In a child comment wnoise says that "every bug that is found should have a unit test written". For the record, I don't agree with that either. Take this bug: "In Opera 10.2 the mousewheel delta comes in with the wrong sign, which breaks zooming." (I can't vouch for the exact version, but I do remember that Opera pulled this trick once upon a minor version update.) It's a very typical bug, I get hundreds of those; but how do you write a test for that?

You could say web development is "special" this way. Well, it isn't. Ask game developers what their typical bugs look like. (Ever try writing a 3D terrain engine test-first?) Ask a Windows developer fighting with version hell. Honestly I'm at a loss for words. What kind of apps have you seen developed with TDD start to finish? Anything interesting?

Maybe related: Ron Jeffries (well-known Extreme Programming guru) tries to write a Sudoku solver using TDD which results in a slow motion trainwreck: 1, 2, 3, 4, 5. Compare with Peter Norvig's attempt, become enlightened.

Comment author: RichardKennaway 04 October 2010 01:23:07PM 2 points [-]

Ron Jeffries (well-known Extreme Programming guru) tries to write a Sudoku solver using TDD which results in a slow motion trainwreck: 1, 2, 3, 4, 5. Compare with Peter Norvig's attempt, become enlightened.

The main difference I see between those is that Norvig knew how to solve Sudoku problems before he started writing a program, while Jeffries didn't, and started writing code without any clear idea of what it was supposed to do. In fact, he carries on in that mode throughout the entire sorry story. No amount of doing everything else right is going to overcome that basic error. I also think Jeffries writes at unnecessarily great length, both in English and in code.

Comment author: cousin_it 04 October 2010 01:51:30PM *  5 points [-]

The problem is, Extreme Programming is promoted as the approach to use when you don't know what your final result will be like. "Embrace Change!" As far as I understand, Jeffries was not being stupid in that series of posts. He could have looked up the right algorithms at any time, like you or me. He was just trying to make an honest showcase for his own methodology which says you're supposed to be comfortable not knowing exactly where you're going. It was an experiment worth trying, and if it worked it would've helped convince me that TDD is widely useful. Like that famous presentation where Ocaml's type system catches an infinite loop.

Comment author: randallsquared 06 October 2010 04:09:00AM 1 point [-]

The main difference I see between those is that Norvig knew how to solve Sudoku problems before he started writing a program, while Jeffries didn't

When you already know exactly how to do something, you've already written the program. After that, you're transliterating the program. The real difficulty in any coding is figuring out how to solve the problem. In some cases, it's appropriate to start writing code as a part of the process of learning how to solve the problem, and in those cases, writing tests first is not going to be especially useful, since you're not sure exactly what the output should be, but it certainly is going to slow down the programming quite a lot.

So, I'll agree that Jeffries should have understood the problem space before writing many tests, but not that understanding the problem space is entirely a pre-coding activity.