5 Ways To Battle Coder's Block

Oct 15 2010

Between a rock and a hard place

So there you are, gearing up to implement the next feature in the application you’re building, and all of a sudden, BAM! Coder’s Block! I’ve hit this a few times over the years. It can be very frustrating knowing what you want the end result of a solution to look like, but not being able to think with a clear mind and pull it off in an elegant way. And I’m not talking about the general uncertainty of not knowing the specifics of the implementation. That can happen frequently and test-first development is probably the best way to combat that. I’m talking about the times when you can’t even seem to get your mind to cooperate with your hands to literally write the “correct” code to solve the problem before you.

As I’m writing this, I’m coming out of one of these funks myself. Part of it had to do with the amount of uncertainty of the larger problem, but the other part had to do with me NOT stepping back, taking my time and really focusing on the problem for long enough periods of time in one sitting. As I’ve pushed myself through another one of these periods, I’ve realized there are specific things that usually help me remove the block and get the code flowing freely again. Here are a few that work for me…

1. Exercise

Recently I’ve been getting back to the gym, specifically to get back to playing basketball again which I’ve always enjoyed. It’s probably the most fun way for me to get really good exercise without it “feeling” like a boring exercise routine. I’ve found that taking a break in the middle of the day to go shoot some hoops has been really good for me to help clear my head when the coder’s block sets in. When I get back, I’m tired physically, but usually refreshed mentally. The other day I was listening to the first episode of the Founders Talk podcast with Geoffrey Grosenbach of PeepCode fame and the topic of exercise came up. Geoffrey talked briefly about how his physical exercise habits help him in his daily work and coding activities. Highly recommend you listen to that one!

2. Phone a fellow developer

Besides being a game show gimmick, calling up a friend and just doing a quick screen sharing session can go a long way. Just the other night I had a friend help explain to me how he solved a very similiar problem I was having. Even though his solution wasn’t right for my situation, it was still very helpful just talk through the problem I was having out loud with another human being. That is certainly one of the challenges of being an indie developer like myself. You don’t always have someone to bounce ideas and problems off of to get feedback. But thanks to a lot of great friends and connections I’ve made over the years and the invention of twitter, being an “indie” doesn’t really mean you’re alone anymore.

3. Solve small problems

Sometimes when I’m stuck on a sizable problem, I find it’s good to table it temporarily and find a smaller problem to solve first just to get the juices flowing again. To help explain, here are the phases I typically go through when solving a problem or implementing a new feature. At the very beginning, I’m usually pretty psyched up and ready to conquer the world with my fingertips. Optimism is high and anything seems possible. That usually continues for a while and things get going smoothly, but at some point I hit the zone of “ok, I need to push through and get this done” so that I can get that sense of accomplishment. I find that the longer I stay in this zone, the more stressed and sloppy I can sometimes become. So by picking off a smaller problem to solve quickly, or better yet break the original problem down into smaller problems, I can plow through it and get that feeling of completing something much quicker and more frequently. And for me, the act of solving a problem or finishing a feature is a huge rush!

4. Play music

Many have expounded on the interesting link between programmers and musicians and how the two often go hand in hand. Having been a long time drummer and percussionist, I guess I fall into that category.

Small tangent

My take on it is that both music and programming require you to quickly go from the 10,000 foot view of things down to the incredibly small details then back up in very short periods of time. Being able to know where you are overall within a drum fill while nailing that individual 16th note at just the right volume is akin to paying attention to the desired outcome of the user registration feature while writing the single line of code that ensures a user gets sent a confirmation email once registration is complete. Well, hopefully that was a good analogy. It made sense to me. :)

Anyway, if you do happen to play a musical instrument, that can also be a good way to get out of the funk of coder’s block. Forcing yourself to focus your brain on something completely different and as intense as playing music, you might just find that when you sit back down to code, you have a renewed outlook on the problem at hand with a fresh set of ideas. Although it probably won’t sound as good as that killer open-hat funk groove you just invented on the drum kit.

5. Blow stuff up or kill aliens

Ok, so maybe this isn’t the most productive item in the list, but it’s gotta be worth a mention. After all, it does improve decision making! :) Admittedly, I don’t get to do this one all that much, but sometimes when I get stuck on a code problem and start thrashing, a few minutes of Gears, CoD or Halo can be a good break from all that serious work stuff.

What about you?

So dear reader, what helps you get through the dreaded coder’s block and get the code shooting out your fingers again?