I was thinking about what I like about Test Driven Development this evening. It strikes to the heart of me and my desire for instant gratification - I get feedback about how my code is progressing far faster by writing a test first and then the code to implement a given feature. It harks back to my initial days writing BASIC programs where I would frantically type in a bunch of code and run the thing just to see what effect I’d had. During university I was taught that this is bad and that real adults are those who curb their desire for instant gratification and look for he delayed gratification of the whole development cycle revolving. I was taught design - code - test. Nowadays its all about test - code - design, if that can be believed, and it has returned to me the sense of progress I have been missing all this time.
Writing a test first is easy. They are small and you get to a point of something runnable really quickly. Then, you the get the pleasure of taking a nasty red “it failed” message and turning it into a big green “success!” message. Talk about gratifying! Theres a constant flow of satisfaction in a job well done. Automating the tests is an absolute must. It wouldnt be nearly the fun that it is if I had to go in and type values into fields over and over again. Thank goodness for tools like JUnit!
Writing the test first also helps in knowing when to stop. If the test passes, the code is done. It might not be elegant, but it does the job. For someone who has a tendancy to be a perfectionist, thats a huge relief! I have an outside, objective, measure of what to do and when I can stop and look for something else to tinker with.
Writing the tests also makes it easier from an open-source perspective too: if someone else downloads the code they have confidence that it all works simply by running the tests. Better still, I have confidence in their improvements because the tests still pass. If there are new features written test-first, someone else has a clear measure of what they can do to aid the project. All in all, a winner for the free software world!

