Mittwoch, 19. März 2008

7 reasons why test-driven development rocks

Did I ever mention that test-driven development rocks? No? Well, it sure does :)
Here are my top 7 reasons:

  • Know when you're done. Back when I didn't have tests prior to implementing functions I never was sure when the implementation was actually done. There was always this unspecific feeling of having forgotton something...

  • Reward. Everytime a test passes, I get this satifying feeling of having accomplished something :)

  • Efficiency. Writing tests forces me to think about solutions instead of thinking about problems.

  • Better software design. Writing tests before implementing the actual method forces me to think about what exactly I expect the method to do. Methods that are awkward to test are awkward to use, and require redesign.

  • Refactoring. You simply cannot refactor your code without having tests in place. But if you have tests, refactoring is a breeze.

  • Confidence. Having tests in place makes me confident that my code does what I want it to do. Well, most of the time... But when I encounter a bug I add another test and regressions won't hurt me.

  • Example code. Test functions are concrete examples how to use a given function in my code.


I would have liked to have 10 top reasons, but couldn't figure out the remaining three... If you have one, please comment!

Keine Kommentare: