12 points · by stesch · 16y ago · 6 comments
He admits the benefits of TDD and the next paragraph turns on the proponents of TDD (which is not all there is to agile, but that's another story).
Every shop I've worked in, I've had to sell TDD, and every time it's been varying degrees of slog, and at the same time, we've been able to develop faster: random things weren't breaking since we had tests to catch things like that (and if things did break, we wrote more tests to catch that too); having developers leave or hiring new developers were less of a risk because there were examples of working code and because there were tests to buffer the learning curve; major refactors were less scary because end-results could still be validated even if a large part of under-the-hood had changed.
Sure you have to be sane - the one-off prototype doesn't need the same degree of TDD as the platform that's going to be around for 5 years, but you still need a way to validate your results. And yeah, sometimes the tests come after the code, but the tests still need to be there.
How about a test that picks a bunch of random x values, and calls the function to get f(x), then checks to see if those perfectly fit an exponential curve?
Now, every time you run the test you should read in this file and compare the results that you get running the function with the results contained in that file (which were already verified to be correct.)
This doesn't ensure that the calculations are done correctly, but it does ensure that after future code changes the output remains consistent.