Quality & Code

06 Jul 2012

I always want to avoid anything that might be called self-righteous or hypocritical, but please excuse me if I venture into that territory. This post is as much a manifesto for myself as it is a criticism of anyone else.

As a developer, you spend far more time reading, maintaining and refactoring code than you do writing it, yet it seems still that many value code that “just works” over that which is well thought-out, documented and tested. This minimises the time it takes to write the code, but is a surefire way to give yourself monstrous degugging challenges later.

I suggest that, if your intention is to open-source your work, or have others work with you, or just to work on the same piece of code more than once, you should be investing time in code quality, aesthetic and algorithmic, and in documentation and tests. In fact, I see it almost as matter of pride.

My thoughts turned to this because I’ve come across a worrying number of open source projects from well-known developers exhibiting dire code quality. If you want others to contribute, please make it easy. Please.

I believe it’s linked to the subconscious desire, perhaps instinct, of a developer to avoid rendering themselves redundant within a project. If you’re the only person who can successful make changes to a piece of code then you’re effectively cementing yourself into the code base. I hope I don’t need to explain why that’s obscene.

I’m not naive enough to suggest that everyone, particularly those working on internal code to a tight deadline, can invest energy in comprehensive test coverage and detailed documentation for entirely practical reasons (it’s possible that’s down to the attitude of management too, since it’s hard to justify, to a client, hours spent writing documentation), but even in this arena things could (should) be better.

While I won’t hold myself up as a beacon of code excellence, I would like to think that I do my best and that I’m always striving to get better at it. I’m very much obsessed with the way code looks and reads; code is poetry and I want to be a laureate.

For me, keeping up with best practices and learning entirely new techniques to sharpen skills in my language-of-choice are vitally important too.

Give a shit about your code, and others will too. Take pride in it. Don’t give potential collaborators the middle finger before they’ve even begun.