Keep It Light

Code is serious business. It’s not always mission-critical, life-dependent stuff, but any programmer who’s spent long nights furiously trying to extinguish an inexplicable bug knows that it’s often no laughing matter.

Yet I, and I think many in our careers, suffer from a condition called codeaphilia, a love of coding. The practice of it. Despite the frustration, the harsh deadlines, the constant quest for perfection (never achieved) and the thankless rewards, this is what I love to do. But it’s still serious business.

I think of programming as a creative pursuit. From issues as prosaic as how to position a text field, to a problem as vexing as how to properly manage data sync between client and server, I have to bring all my creative energies to bear. The rush I get from correctly solving a problem is why I keep doing it.

Still, there are a lot of long, difficult hours between start and finish. And as I’ve been coding for many years, I’ve developed coping strategies. One that I happened to post on Twitter yesterday went like this:

Screen Shot 2014 04 16 at 10 56 06 AM

Ha ha, I thought as I typed that out. A pressure valve opened, and I continued on with my coding with renewed energy.

Then, my dear friend Farley responded:

Screen Shot 2014 04 16 at 10 57 57 AM

Well, sorry Farley, but this is how I do. Yes, I later removed my reference to Chaotic Good Alignment… but only because I couldn’t think of a clever enough implementation for that particular option!

As I thought about this rebuke from someone I respect, it occurred to me that, dammit, I think humour in code is a good thing! Obviously, you don’t want to take it too far, but thinking back on the code I write, I know that I take pleasure in writing pithy comments and variable names that make my job a little more enjoyable.

Some examples:

  • When building up a complex cluster of class objects, I like to quote the great Carl Sagan:

    /* "If you wish to make an apple pie from scratch, you must first invent the universe" */

  • When doing some routine data setup tasks, inject quotes from Star Trek. This was a happy serendipitous discovery months after I wrote it:

    /* "Good tea. Nice house." -- Worf. */

  • When naming variables or methods in Objective-C, remove the stuffy tie and breathe, dammit:

    (void)destroyAllTheViewControllersWithExtremePrejudice;
    NSInteger countingKitten; // a simple incrementor
    NSView * ninjaView; // a background view that slides onscreen after init

No, this is definitely not the behaviour of an adult professional. And yes, I definitely cut this stuff out when I’m working on shared codebases with other developers.

But when I’m working on my own projects, you bet I inject humour into the code. It reminds me that I’m building a thing for humans. And I think when you challenge yourself to be funny, you’ll engage the part of the brain that will be more creative in problem-solving.

Back to coding! Ha ha!