Friday, 18 May 2012

We are in desperate need of rapid feedback, whether we're aware of it or not

Today, I was adding some code to a codebase that had no unit tests (nor did I want to write any), which I haven't done for a long time, when I caught myself taking shortcuts and hacking bastardly on the code, making it less maintainable. How did it happen?

Me, who always strived (more or less successfully) for clean code and test driven development, ended up hacking all over the place.

After having a tea, I figured out what happened. I desperately needed rapid feedback. Taking shortcuts and writing bad code shortened my path to production environment where I was verifying whether the change was correctly made. "Just put this hack over there and back to debugging". What's more, it reminded me the times before I got into TDD - I was doing the same then. So it's not TDD that raised my need for this feedback - it has always been there. It's just that I have become aware of it.

And I think this is often the reason why knowledgeable engineers write crappy code. For them, this is a sacrifice on the altar of rapid feedback - if only they knew that by doing TDD, they would not have to sacrifice anything...

It's funny how TDD is accused of being unnatural ("what? Test First? That's insane!") while at the same time satisfying our most natural need.

Good night, everyone!

No comments: