Wednesday, May 13, 2015
The True Value of Test First Development (TDD)
This week I was able to show someone the true benefits of test first, actually we are doing a form of Behavior Driven Development (BDD). With respect to one of the true values of writing test first though, its all the same. You may think the true benefits are defect free code, change with confidence, and isolation of modules. You'd be right of course that these are benefits, but there's more - design and efficiency. We stayed the course for a bit with respect to writing tests first, but at the pleadings of the mentee I decided to just bang out some code as an experiment. We talked about a design for the API function that we were designing and I went ahead and wrote the interface and implemented it. Then we circled around to the tests and began to change them to suit our new implementation...that's when the proof showed up in the pudding! It turns out that our design was not going to work out so well. We wasted time writing it and now we had to waste more time retrofitting the tests. The only thing to do was to start with the test, write the interface we needed, then redo the implementation. When we start at the end, we know how to go best.