Hacker News new | ask | show | jobs
by n1ghtmare_ 4391 days ago
This is a strange debate these days. For me TDD made me a much better programmer. I'm not sure how I used to work without it. It saved me on many occasions. It does lead to better quality (from my experience). Frankly I don't see a single downside. Seriously.

Is it hard ? Sure.

1 comments

The most significant downside is opportunity cost; all code is eventually throwaway code, and if you are doubling your authoring burden by writing code and tests on a throwaway prototype, you are iterating half as fast as you could be.

But in my personal experience, most programmers err heavily on the side of failing to test thoroughly something that will become a long-term solution, not on the side of over-testing their throwaways.

It sounds like you write your tests based on the code you write rather than its expected behaviour.

You can write a good set of tests when you know the initial requirements, and not all requirements iterate at the same rate as the code. As you learn new requirements, you write new tests. The old ones don't go away (nor do the early requirements if they're good), even if you completely replace the implementing code.

> You can write a good set of tests when you know the initial requirements

Throwaway prototypes are part of the requirement discovery process.