by kscaldef · 17y ago · 0 comments
1) You aren't perfect.
2) Your coworkers aren't perfect.
3) Your "abstractions" are still code that can have errors in it
Also, you are misunderstanding the argument that TDD speeds you up. Yes, at the micro level it may take a bit more time. But, as the system grows, your ability to add or change functionality without breaking things increases when you have tests to verify that it is still correct. (Also, automated testing is much, much faster than manual testing.)
I disagree unless all your changes are really shallow. You change the structure of your application in significant ways and you'll break the tests too. So now you have two problems.
You have some big tests that are general and test that all the components work together, but for each component you have lots of little tests, and if you are going to change the component you change the tests FIRST. That's TDD.
You deliberately break the tests before you change one line of the actual code.
Now certainly writing everything twice is actually a great way to catch errors. NASA does that with the shuttle. But I wouldn't argue that its faster.
I prefer to just liberally sprinkle my code with run-time assertions. We have a small defect rate even after pushing out massive structural changes to the application. The bugs that we do have tend to involve an unpredictable set of conditions that no automated test would ever be written to find.
You are correct sir! What the tests do is allow you to refactor (reorganize or clean up code) and verify that you haven't changed functionality. That's the theory.
In practice however you are hardly ever refactoring for its own sake. In most cases you can't really justify paying developers to change code without some benefit that someone (i.e. a customer) will pay YOU for. And as soon as you start changing behaviors, you now have to change code and tests (or write new tests).
Well, I'm not perfect, but I aspire to write perfect code, that is, code which has no bugs. One way of doing that is writing unit tests - telling the computer what to do, and then telling it how to check what I just told it to do. A better way is making sure I'm using abstractions that match my intentions.
Aside: I see TDD as a little different from regression testing, which seems to make a little more sense.