Tuesday 27 January 2015

Overcoming Developer's Block

You know how it is - however brilliant you are, however experienced, sometimes your code just doesn't work the way it's supposed to. You trawl through your code, looking for a syntax or logical error. You find nothing. But you know it has to be there.

The dreaded Developer's Block. It's not quite the same as Writer's Block. With Writer's Block, the writer has no idea what to write, or how to proceed. With Developer's Block, the developer already has the specifications (and if you don't, boy, your problems are far bigger) but midway through coding, something went wrong. Not only do you not know how to fix it, you may not even know what the problem is!

We're not going to address debugging techniques here, or common rules of thumb. Everyone's got their own rules, and I'm sure, on their day, they're very effective.

But the rule I'm going to present here may just be the most important of all. The last resort.

Walk Away

That's it? "Walk away"? I can imagine some of you snickering right now.

No kidding! Well it's certainly the simplest way I can put it, so allow me to elaborate with examples. Below is a paraphrased conversation between me and a fellow developer colleague. He was experiencing the dreaded Developer's Block and tearing his hair out.

Him: I don't know what's wrong. This output looks weird! But no error message!

Me: Hmmm. Let me have a look.

(a minute passes)

Me: Abang, this is a nested For Loop. How come inner and outer loop are using the same variable?

Him: Oh my God. You're a genius! I've been looking at this for hours. You come in for five minutes and find the problem right away!

Me: I'm not a genius, and I'm not better than you. I just haven't been looking at this damn thing for hours.

And that's the simple truth. Focus is good, but when you concentrate too hard and too long, you risk getting tunnel vision, or, more poetically, "missing the forest for the trees". Walking away, or taking a break, helps your brain reboot. Of course, the best way to reboot would be a nice 8 hour nap, but failing that, 10 to 15 minutes potentially works just as well.


Take a break

Take a walk. Have a smoke. Go cake the porcelain. Or take a walk to the loo and have a smoke while caking the porcelain. Whatever you do, keep your eyes away from the computer screen. The answer, or at least a path to that answer, will arrive when you least expect it. Many times I gave up in frustration and left the office for dinner, only to have the answer pop, unbidden, in my head through my first mouthful!

Tackling the mental wall

Think of your problem as a concrete wall. At the risk of sounding cliched, you don't need to keep banging your head against the wall, hoping to break through. You can just as easily go over, around, or under it. Or you could think about it further and realize that you don't actually have to deal with that wall in the first place!

That's enough for now! I'm gonna take a walk and... cake the porcelain.
T___T

No comments:

Post a Comment