Got coder’s block? Here are 12 real-world methods for breaking on through

Like writers, software developers can also get stuck staring at a blank screen. Here are a dozen common ways programmers get code flowing again.

Man with his head resting on his laptop
Credit: Thinkstock

We’ve all heard of writer’s block; that is, when a literary type just can’t figure out what to write. If you’re a programmer, though, and done it long enough, chances are you’ve experienced a cousin of writer’s block, coder’s block. Like writers, programmers can have hours or days (or longer) where they have trouble writing code, or writing good code or just feeling like they’re “in the zone”.

Programming isn’t just about following instructions and making something work; it’s a much more creative process than most non-programmers think. There are often a near infinite number of paths to implementing a given functionality. Plus, programmers, like anybody else, can have lots of different projects on their plate, and sometimes simply deciding what to tackle first can be daunting and can prevent you from getting started on any one chunk of work.

Your average software developer, then, can be just as blocked staring at his or her favorite code editor as a writer can staring at a blank Word document. It’s a real problem for some. Luckily, it’s a topic that developers will often discuss, with many sharing the techniques that worked for them in dealing with coder’s block. Here are 12 common methods that programmers use to help them break through the logjam and get the code flowing again.

See also:

Superbugs: 10 software bugs that took way too long to meet their maker

Exposing the source: 15 pieces of classic software whose code is now accessible

Keyboard for one: 8 of the most impressive solo programming efforts

Head-scratchers: 10 confounding programming language features

Superclass: 14 of the world’s best living programmers

Pants on fire: 9 lies that programmers tell themselves

Restroom sign
Get away from the computer

One seemingly obvious solution to coder’s block is to just get away from the computer. It might be to read a book or magazine, to go for a walk or even to answer the call of nature. Getting your eyes away from the monitor and your brain engaged in something non-computer related can help it get out of whatever rut it’s stuck in.

Quotes

“The computer is just a tool, after all, and sometimes one needs to put aside the tools to get a better look at the problem.” tuffy

“If I'm buried in VBScript, taking a break and reading Vogue or Elle either refreshes me enough that I can jump back in, or it sparks something in the grey matter so that it comes up with a solution to whatever problem I was grinding away at.” MonaLisaOverdrive

“... no matter how tired you are, devote some time (even few minutes) to something completely unrelated. It is important that it is completely disconnected: it could be a math book, a guide to photography, to musical theory...” Francesco

“Go to the toilet. Some of the best inspirations have come while sat on the crapper, trousers around my ankles.” Anonymous

Sign that says 11th Commandment: Thou shalt drink coffee
Drink more caffeine

Programmers (and techies in general) have, of course, a reputation for drinking lots of caffeine. Whether it’s in the form of soda, coffee or tea, caffeine often helps to fuel developers during hackathons and other long coding pushes. It’s natural, then, that when faced with a coding block, some developers advocate increasing the caffeine intake, the consequences be damned.

Quotes

“Grab Coffee!” Rob Cooper

“Caffeine - The more I read, the better this stuff gets. It's a buzz with few tradeoffs, and it even might help you avoid some bad things.“ mmaddox

“The only way to cure programmers block is a direct infusion of skittles and mountain dew intravenously, keeping the brain in an alert and creative state.” TheReverand

“‘Coffee gives me the serenity to think and the vitality to act’ - attributed by my own admittedly faulty memory to Kurt Vonnegut in a coffee commercial.” snoopdave

The exterior of a former Starbucks
Quit drinking caffeine

There’s a real divide in the programmer community over whether coffee and caffeinated drinks, in general, help or harm developer productivity. It’s no surprise, then, that while some developers strongly advocate increasing the caffeine intake when blocked, others just as strongly argue for decreasing or eliminating its consumption completely. Caffeine, some feel, can be the cause of coder’s block in the first place.

Quotes

“This is a symptom of caffeine addiction. Inability to concentrate, anxiety, etc..” orev

“... look at eliminating caffeine. I'm less jittery, and the adrenaline doesn't seem to fire off everytime something goes wrong.” RunFatBoy.net

“In my experience, coming off the caffeine for a few days restores my creative thinking when I'm stumped.” gwicks

“... caffiene is the fruit of the devil. Sometimes I find it necessary… but it won't help you solve a problem.” MrResistor

A man skydiving
Get some exercise

Programming can certainly be a stressful job and, no doubt, coder’s block can be partially caused by too much stress. Consequently, exercise, which has been shown to help prevent depression by relieving stress, can also help get you back into a productive coding state of mind. Experienced developers often find that physical activity is the best cure for coder’s block, whether it’s something as simple as a walk around the block or as exciting as jumping out of an airplane.

Quotes

“Take care of the body and you're taking care of the mind.” Mr T

“My friends and I used to go to the park and swing to think.” Momo

“Skydiving and Flying are great sports. They're relativly not that expensive ... and they get our bodies moving, and our brains thinking in a different way than we're used to.” _14k4

“Your brain needs oxygen, and a lot of it. If you’re sitting at a desk all day, not moving and not getting any blood circulation to carry oxygen around your body, you’re making yourself dumber.” Starr Horne

Man playing a trumpet
Play an instrument

Most non-programmers wouldn’t think of software developers and musicians as having much in common. However, many developers, in fact, like to play music in their spare time and will often to turn to an instrument to help them get through coder’s block. The act of playing an instrument engages both the brain and the body, but in different ways from programming, which can help break the block. There’s no evidence, though, that musicians turn to coding to breaking their “composer’s block.”

Quotes

“I've taken to playing guitar to clear my head, both when I get stuck on a problem, and at the end of the work day to get out of ‘work mode’.” Neil White

“Whenever I get ‘coder's block’ I play guitar and it refreshes me. Fantastic way to get back in the groove.” John Papa

“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.“ Joey Beninghove

“...we brought in musical instruments… a guitar, a bass, a didgeridoo... instruments hanging from hooks on the wall, just calling out to you anytime you had coder’s block and needed a few to get your neurons to fire around the problem instead of slamming your head against the wall.” Tom Tarka

Man listening to music with headphones
Listen to music

Music, it was once said, has charms to soothe a savage breast. Turns out it can also help to soothe a blocked coder’s brain. Some developers will turn to something loud and upbeat to get the juices flowing, while others prefer something quiet and calm. Some advocate instrumental only pieces, to avoid the potential distraction of listening to lyrics. Whatever your musical tastes, just be sure to wear headphones so as not to prevent your coworkers from getting their work done.

Quotes

“Turn on some really loud, energetic music (I find trance/techno works wonders). Just make sure it's all instrumental; words will destroy your concentration. ” phee

“Put yourself through some spiritual experience. Like, going to soul-related material, it could be your favorite music ….” Reet

“I have a set of ‘programming CDs’ that I find help me a lot when I'm lackign focus. They give me a kind of ‘artifical energy’ that keeps me going.” catseye_95051

“I can honestly say I have never had a mental block that a Miles Davis album could not cure. Either that, or some Slayer!” TheOutlawTorn

Guy sleeping at his desk, slumped over his keyboard
Get some sleep

Sometimes to break coding block you need to do more than just get away from the computer screen; you need to let your brain (and body) relax completely. Many developers advocate dealing with a block by hitting the sheets, or at least the couch, for some quality sleep. A power nap may be all you need or, in more severe cases, your body may be crying out for one or more long nights (or days) of sleep. Just try not to drool on your keyboard.

Quotes

“The solution is easy: get some good sleep! … there’s nothing like a good night’s sleep to clear your mind. If nothing else helps, close up shop early and sleep on it.” Starr Horne

“Sleep for as many hours straight as you can.” Electric Barbarella

“On really bad blocks I take a mental health day or two, sleep in really late, (gotta rest that overworked mind)....” lostproc

“If I've been in an unsuccessful "okay I need to push..." mode for too long, I go to sleep for 20-60 minutes, thinking about the problem as I drift off. When I get back, there's often a "why didn't I see that before" moment” DaveEveritt

A bunch of boxes that say Test
Write unit tests

When programmers feel unable to write code, a common recommendation for breaking through the block is to break the task in front of him or her into a number of smaller tasks. A great way to do that is start by writing unit tests. Breaking things down into unit tests also helps to provide focus and structure which might be just what the developer needs to get the code flowing again. 

Quotes

“Writing unit test first... makes you think out the problem ahead of time and allow you to code fearlessly. You don't have to worry about your changes causing damage else where in the system because every piece of code has automated unit tests that should all pass.” uqbar

“I usually start with unit tests, and use that as a test runner/harness, which has a nice side effect of being tests, and small blocks of work“ Nic Wise

“For me, getting over coders block has been one of the most important unexpected benefits of unit testing and test driven development.“ reefnet_alex

“It virtually eliminates coder’s block.” Tim King

A woman meditating in a park
Credit: REUTERS/Brendan McDermid
Meditate

Sometimes just getting away from work or the computer isn’t enough to break through the coder’s block. You may have to work harder at clearing your head and stopping the wheels from churning for a bit. Some developers say that meditation is a great way to achieve some clarity, reset your brain and hopefully clear the coding blockage.

Quotes

“Learn meditation - I don't mean meditate on the problem, I mean totally clear your mind. Works best for me at night. If I can get the conscious mind to "shut up for a while", it often jump starts my creative process. I've ofter dreamt the answer to problems after doing this.“ torcail

“I like to make an analogy to meditation as being like defraging the hard drive, flushing memory cache, and throwing out temporary files.” master2b

“Pushups, stretching and meditation get the brain back in order.” anal0gue

“One thing you do in meditation is to stop thinking. Hardened programmers might find that a frightening concept.” goingware

Woman arguing with dog
Talk it through out loud

When having trouble to trying to code or solve a particular problem, developers often find it helpful to talk through the problem out loud. Sometimes, discussing the problem with another programmer will do the trick. Often, though, many find it more useful to describe the issue to a non-programmer, or even a non-person. Your sounding board could be a pet or an inanimate object - or nothing at all. Just verbalizing the issue in some way could help break the logjam.

Quotes

“Talk to another developer, ideally in front of a whiteboard. Nothing makes things flow better than trying to explain them to someone else.” Gregory Seidman

“Often times trying to describe things to a non-developer can be much more illuminating.” AndyV

“Now this is going to sound silly, but I've even talked to my cat when working at home and sometimes had that 'eureka' moment.” LizardKing

“I’ve known of people who, when faced with a complex issue like this, actually bring a stuffed animal into their conference room and discuss the problem with it.” Starr Horne

“I talk to my dog much more often than I probably should“ chowda

Dump truck unloading gravel
Just write some, or any, code

Just like for blocked writers, many programmers recommend writing something to help break through the block. Some developers recommend falling back to coding something simple, that you already know how to do, to build up your confidence. Others recommend working on something fun and different to get your brain back on track. Yet others say just dump some code out of your brain, no matter how bad, inefficient or useless. The idea is that even just going through the coding motions can help get your juices flowing again.

Quotes

“One way out of writers block, which works for my programmer's block, is to write Something, Anything. Junk throw away code. Just explore something. Don't worry about solving some problem, just Do.” Brian Leahy

“The trick is just writing/coding. The more you write and the more you code, the more good stuff you get out of your head and into source files. You might throw it all away and keep just one concept. But you will find the pressure has eased and suddenly the direction you need to take is clear.” Kostya

“What works for me ... is to take Sedgewick (or any classic text) and write one of the algorithms in there. Doesn't matter what it is…. The result is you realise you *can* program after all and you'll have probably learned something in the process….” mav[LAG]

“As a professor of mine once said, ‘if you can’t write, write shit.  We have delete keys for a reason.’” Steve Havelka

Guys with laptops on a couch, behind a sign that says Will code for food.
Find a new job

If all of these methods fail to resolve your coder’s block, it might be time to consider a more drastic solution: finding a new job. Your blockage may really be a reflection of bigger issues with your employment situation. Perhaps you’re working too hard or you’re ultimately not happy with what you’re doing? Clearly, it would only be a last resort.

Quotes

“Though often easier said than done, finding another job is sometimes the only way to remedy coder’s block. Only you know if it’s your job itself that’s causing your issue or if it’s simply a case of bad habits and long hours. I think this is a last resort option.” Bill Patrianakos

“Finding another job at a different company is the best method I have found as these symptoms are usually a dissatisfaction with your employer rather than the job.” drekka

“... if it's not just burn-out consider getting out of the job.” LizardKing