This article originally appeared in Dev.Mag Issue 29, released in February 2009.
I must confess. I hardly ever comment my code. It’s the sort of thing that everybody lectures about, saying that it’s important for clarity, ease of use and even national security in the event of nuclear war. This is all true (though perhaps the nuke idea was a bit of a thumbsuck) and I will always advise others to write miniature essays in their game code.
Unfortunately, I fail horrendously when I need to do it myself.
I’m well aware of the temptation to postpone commentary, skip it for minor sections, or abandon the whole idea due to a sudden irrepressible urge to pee. Of course, such thinking tends to be rather shoot-in-the-foot-ish – experience shows this. But these mistakes keep being made by many eager devvers. They seem as unavoidable as going off to play Guitar Hero when, say, one is supposed to be writing the opinion column for Dev.Mag.
In a recent game prototype of mine – an Incredible Machine tribute containing little force balls and the Photoshopped head of an unwilling friend – I decided to see what would happen if I threw my own personality into the programming comments. Gone were the dry and crusty “//algorithm x for operation y” explanations – I took it upon myself to slip the colloquial, the abstract and the downright weird into my non-compilable statements. The results were amazing: I immediately felt motivated to comment my work more thoroughly, to think of something witty and interesting for each little code block that I came across.
I brought the “lol” back into my code. I injected some fun into tired tasks, and not only did I comment more frequently, but I started to enjoy the coding process more. Heck, none of us became programmers so that we could be bored stiff by our duties – it just happens to be an unfortunate reality that we end up frequently trawling through menu generation and file-handling procedures when we want to be doing something really cool instead.
So if you’re struggling to comment properly or are lurching through tedious code, try let go a bit and have a little fun with your work. Make wry remarks about your data structures. Express frustration, joy or relief with individual blocks. Maybe even take a step outside the comment zone and start renaming a few variables or functions instead. It’s your program. Do whatever the heck you want with it.
I’m not suggesting that you make your work incomprehensible. Far from it. You just need to realise that there’s more to coding than tiresome programming platitudes. Have a bit of fun, put a little life into your work, and remember that ifa you do something often enough, you ought to at least enjoy it.