Wednesday, October 13, 2010

A Codefession

"Forgive me Father for I have sinned, It has been 3 iterations since my last confession."

I was brought up a Catholic and one part of being a Catholic is Confession. It's great! You do a load of bad stuff (sin), tell a priest,  he gives you a penance and then he absolves you.
Now that the slate is clean, you can do loads of bad stuff again until your next confession. (I think that's how it works).

When coding, I'm a good boy. I've read the various gospels. I even try and write my code so I don't give in to temptation. And, oh boy, there is temptation. The devil manifests himself in many ways.

There's the temptation to hack it together because you're going to fix it later. The devil knows this will never happen. The devil can be in the form of a looming deadline. You're under pressure and so your good intentions go straight out the window. The devil can be that you are working in an area or language that you are unfamiliar with.

Well I let the devil into my life the other day, I'm ashamed to tell you Father, I sinned. I wrote a real bit of untested, hacky code the other day. Just thinking about it makes me feel guilty. I fixed a defect but at the same time made that bit of code a little bit less maintainable. I broke the boy scout rule.

Ok...lets drop the metaphor. Programmer writes crap code under duress. Is this acceptable? Well, it depends. In an ideal world all my code would be written like an angry Agile Alliance was stood behind me with baseball bat but we all deviate from time to time, even Saint Corey! I think the most important lesson is to understand the reasons why you have strayed.

Be honest with yourself, why did this happen? What can you do to prevent this happening again? I've done my own retrospective, I guess this blog post is part of it. I know what went wrong and I hope I'll recognise the signs that it will happen again. And when I see those signs I hope I can do what I can to mitigate the circumstances that force me to right it.

I've pulled this into the sprint reviews too. When I've not achieved what I set out too, I want find the root cause. We've not being doing this and I've no idea why. After all, Scrum is not going to solve your problems, it’s just going to make them in-your-face obvious, every day. I've been thinking about XP values recently too. Without courage and communication and to a certain extent feedback we are setting ourselves up for a failure.

In the talk by Software Craftsmanship, Beyond The Hype, Corey Haines talks about when you have to get stuff done quickly you drop back to the skills you find instinctive. It takes time to learn techniques (such as TDD). Its a natural process. That's why practice and honing your technique are important and that's why just coding in work time doesn't give you the time and space to perfect your skills.

Ok metaphor back on.

Father: My child before I absolve you this is your penance. Say 20 Hail Ruby's and do 10 Our Katas.
Me: Thank you Father, see you next week!

No comments: