Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think there are a lot of things whose appropriateness is hard to know unless you have some experience with it. That's especially true where you're trading short-term costs for long-term wins.

For example, think of restaurant hygiene. Safe food handling is hard work. And if you skimp on it, it's easy to say, "Hey, doing X isn't really necessary; nothing bad happened."

For me, TDD is similar, in that the benefits mainly come later, when you have a sizable code base that you can make big changes to without fear. I agree people should use it when appropriate; there are definitely times when I don't bother. But I'm concerned that people who haven't experienced success (and failure) with TDD will have poor intuition for when it's appropriate.



"For me, TDD is similar, in that the benefits mainly come later, when you have a sizable code base that you can make big changes to without fear."

The ability to refactor without fear comes from having adequate test coverage. Whether you write the tests before you write the code (TDD) or after the code is completed doesn't seem to affect your ability to refactor at a later date.


For me, it definitely affects the quality of the tests. Once I've written the production code, I know how it works, so its faults are harder for me to see. I also find it's easier to leave coverage gaps. I think I could get some of the same benefit by bringing in somebody else to review tests without looking at the production implementation, but I haven't tried.

The other thing I think TDD gets for me is cleaner API design, because my orientation begins (and mainly stays) outside the thing I'm working on. And cleaner design definitely makes refactoring easier.

Of course, if people have tried it both ways and feel they are getting the same results with some other technique, that's great. But one can only measure long-term maintainability by maintaining a code base for a while, so I think regardless my point on needing experience to judge appropriateness of TDD stands.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: