Ionrock Dot Org

by Eric Larson

My Weblog

TDD gets you in the Zone?

I just read a blog post about how TDD is able to get you in Zone consistently. TDD has always been difficult to integrate into my workflow. It is clear that writing tests is a "good thing" and that it helps to write better code. In fact, I'm now of the opinion that tests are truly necessary in a dynamic language like Python because without tests, there is no way to follow the data. If you don't believe me, write a script to find where a specific object is used in codebase. It is near impossible because the type information is meant to be hidden. Testing allows you verify your application is working as it should.

Lately, I've been writing tests slightly more diligently, and it has paid off. When I had to switch functionality, it was trivial to just rerun the tests and verify things would still be working as they should. What's more, I've had fun writing the tests because it is something I get to start from scratch. It is always fun to create a new file and start fresh, and often times writing tests is exactly that. What's more, you get to write mock objects and helpers to replicate interactions. For example, in testing something at work, I needed to write a helper object that allows streaming file uploads. It was fun putting together a rather helpful little object for sending multipart/form-data uploads. I even was able to write a small command line tool to make testing things out even simpler.

This is a pattern I could really see working. Even if TDD ends up becoming an avenue to tinker with new things, I'm ok with it. Getting in the Zone is pretty awesome. There is most definitely a high. In fact, we just played a CD release show here in Austin that went very well. I'd say the "high" after the show is pretty similar to get in the Zone with some code. I'd love to play huge shows every night, but that is going to take a while. At the very least, I can try writing more tests and seeing if that lets me rock Emacs a bit more and get in the Zone consistently.

Posted Mon Jan 26 17:47:17 2009 by Eric Larson

Twitter

Links

Reading

Created using Python, jQuery and Emacs