DSimon 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: jimrandomh 28 September 2010 07:34:39PM 15 points [-]

Test-driven development is a common subject of affective death spirals, and this post seems to be the product of one. In general, programmers ought to write more unit tests than they usually do, but not everything should be unit tested, and unit testing alone is absolutely not sufficient to ensure good code or good abstractions.

Writing tests is not free; it takes time, and while it often pays for itself, there are plenty of scenarios where it doesn't. Time is a limited resource which is also spent on thinking about abstractions, coding, refactoring, testing by hand, documenting and many other worthy activities. The amount of time required to write a unit test depends on the software environment, and the specific thing being tested. Things that involve interactions crossing out of your program's domain, like user interfaces, tend to be hard to test automatically. The amount of time required to write a test is not guaranteed to be reasonable. The benefits of a test also vary, depending on the thing being tested. Trivially simple code is not worth testing; for example, it would be wrong to test Java getters and setters except as an implicit part of a larger test.

Comment author: DSimon 29 September 2010 04:34:05PM 3 points [-]

I agree with all you've said. I didn't mean to imply by my article that TDD is a panacea, and perhaps I should put a sentence or two in describing that. Mostly the reason I didn't list all the practical exceptions was because I was targetting my article at people with little or no programming experience (hence the lack of pseudo code or particularly realistic examples).

Comment author: DSimon 29 September 2010 04:44:10PM 2 points [-]

Okay, I've added some text about this to the paragraph starting with "Having a sincere desire..."