Morendil 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 04 October 2010 10:27:25AM *  1 point [-]

OK, suppose you are writing Google Maps, from scratch. Is the above the first thing you're going to worry about?

Actually yes - you usually start with drawing a tiled raster map, it's way easier than a vector one. A raster map is just a bunch of IMG tags side by side. But let's go with your scenario of vector drawing, it will serve just fine and maybe I'll learn something:

And the "postcondition" is that the canvas should receive drawing commands to display something in the right line style for a road segment, against a background of the right color, at the right scale.

So the test says "calling this code must result in this exact sequence of calls to the underlying API"? Hah. I have a method like this in one of my maps, but as far as I can remember, every time I tweaked it (e.g. to optimize the use of the different canvas abstractions in different browsers - SVG, VML, Canvas) or fixed bugs in it (like MSIE drawing the line off by one pixel when image dimensions have certain values) - I always ended up changing the sequence of API calls, so I'd need to edit the test every time which kinda defeats the purpose. Basically, this kind of postcondition is lousy. If I could express a postcondition in terms of what actually happens on the screen, that would be helpful, but I can't. What does TDD give me here, apart from wasted effort?

Or, that I've heard of, a tiny little IDE called Eclipse?

Eclipse was developed test-first? I never heard of that and that would be very interesting. Do you have any references?

Comment author: Morendil 04 October 2010 11:17:18AM 2 points [-]

Eclipse was developed test-first? I never heard of that and that would be very interesting. Do you have any references?

Look for write-ups of Erich Gamma's work; he's the coauthor with Kent Beck of the original JUnit and one of three surviving members of the Gang of Four. Excerpt from this interview:

Erich Gamma was the original lead and visionary force behind Eclipse’s Java development environment (JDT). He still sits on the Project Management Committee for the Eclipse project. If you’ve never browsed the Eclipse Platform source code, you’re in for a real treat. Design patterns permeate the code, lending an elegant power to concepts like plug-ins and adapters. All of this is backed up by tens of thousands of unit tests. It’s a superb example of state of the art object oriented design, and Erich played a big part in its creation.

Even with this kind of evidence I prefer to add a caveat here, I'm not entirely sure it'd be fair to say that Eclipse was written in TDD "start to finish". It had a history spanning several previous incarnations before becoming what it is today, and I wasn't involved closely enough to know how much of it was written in TDD. Large (application-sized) chunks of it apparently were.