Saturday, December 11, 2010

My bad code was perfect

Hi, 
I wrote the code below just a few days ago.
Is this good code? No! By most any standards, it sucks. Duplication, bad naming, tests give too little feedback, etc, etc.
Yet, during just a few moments, it was perfect!

To understand why I thought it was perfect I might have to give you some context.
This was the very first few lines of code I wrote in the Io language. Describing my Io skill level as Novice, would be pushing it; at the time it was more like Bambi-on-ice.
I hardly knew any of the language syntax, my experience of prototype based programming was limited and I wasn't even sure about which object my method would be associated with. Needless to say, plugging in a unit test library before I even knew how to make a for-loop was not even on the radar.

Still, the code above gave me just enough feedback, for just enough moments, to know that I was on the right track. And giving me a safety net (or training wheels :-) ) that let me commit, start refactoring, and apply new knowledge as I learned more.

While I can do pretty cool stuff with tools like RSpec or JUnit, it is helpful to remember that BDD and TDD is not about the tools. It's about focus. Focus, right now.

No comments:

Post a Comment