47

Do you suffer from programmer?s block? If so, how do you kick-start your brain again? I?ve been working on a project since I returned from two weeks holiday, it?s a piece of cake to finish, but I?ve done everything except pull my finger out and finish the damn thing.

32 accepted

-stay off of anything w/high fructose corn syrup

-eat a lot of raw foods (peanuts, veggies)

-no processed food

I never believed it myself but your diet has a TREMENDOUS influence on your ability to concentrate. I've also noticed that (for me anyway) I tend to code better when I am hungry and it is early in the morning.

also make sure you don't code for more than an hour without taking a break as I tend to zone out and waste hours surfing the net instead of working.

32

If I'm blocked, it's usually because a task seems too overwhelming to do. I recommend splitting up the task into sub-tasks. Each sub-task shouldn't take longer than an hour, in fact, less is much better. Aim for 10- or 20-minute tasks.

16

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. Pick something that seems halfway interesting that doesn't require too much thinking. And just fart around. Explore something you haven't before, but the emphasis here is Exploration, not learning something completely new.

Somewhere during the processes of writing useless stuff, I get some "juice" back. My brain fires up and I start thinking more creatively. I start thinking, lets see if i can do x, where x may be some feature, technique, or concept I have not ever dealt with.

Inevitably I'll end up motivated and thinking about the project I "should" be working on, and stop coding the throw away scrap once i feel refreshed.

Sometimes, though rarely, the scrap is interesting enough to come back to and review later.

10

I take a walk, buy some coffee, and work a crossword. When I come back later, I try again with the programming part of my brain rested and my focus restored.

I have to take care to not check my email, read slashdot or do other technical work (don't write a solver for the crossword puzzle either, you maniac). This goes to Joel's comments on Human Task-switches, which describes my bad coding days perfectly.

7

Exercising helps. Just a few situps/pushups until you build a sweat. Try it.

6

Allocate yourself a small amount of time, say five minutes, to work on your project. I find that by the end of the allocated time I'm on course for finishing and don't want to stop.

5

Writer's block is a phenomenon when you lack the inspiration to know what to write. You sound like you know what you want/need to do. This sounds more like good old procrastination. Some times it's as easy as just doing it, other times it's not. If you are a chronic procrastinator like me you should check out The Now Habit.

4

Make sure you don't get stuck yak shaving (briefly, doing meta-tasks, meta-meta-tasks and so on for a possibly infinite number of metas) or analysis paralysis. Subdividing tasks is a good way to get past both -- just divide until you have a unit of work you can actually perform right away. At least for me, it's all about gaining momentum from small victories.

3

Set yourself micro-deadlines. Get yourself a countdown timer, either a physical one like a kitchen timer, or a software one - there an numerous freeware ones out there.

Then break the work down into bite sized chunks that can be done in 10-30 minutes. Pick one and use the timer to set yourself a deadline to finish it. I usually start with a 5 minute deadline for the task breakdown. When you finish a task pick another one and work on that, until there are no tasks left.

If you complete the task in the time limit you set yourself then congratulate yourself. If the timer goes off and you have not finished then either estimate a new deadline and reset the timer, or spit the remaining work into smaller tasks. Don't beat yourself up over missing the deadline though - treat it as a game. If you think of new tasks while working towards a micro-deadline then just add it to your list and carry on.

Be sure to include frequent breaks, also using the timer - this will stop you drifting into endless web surfing. I aim for a 5 minute break for every 30 minutes of work. Also schedule occasional periods for stepping back and looking at the big picture, reviewing your progress and replanning your task list if necessary.

For a more formalised version of this technique read up on the pomodoro technique.

2

All I have to say is popcorn. I keep bags of popcorn at the ready for whenever my brain tells me it doesn't want to code and I still need to. Not the buttered stuff mind you, I don't want a greasy keyboard... get the regular salted kind.

When I really need to get going, I set a cup of water/caffeine-delivery-system/what-have-you to the right of my workspace and a bowl of freshly popped popcorn to the left, and away I code!

(In case of absolute emergencies I shake some cayenne pepper and whatever spices I feel like with the popcorn before pouring it into a bowl. BEWARE: Keep a roll of paper towels or a decent napkin at the ready if you do this (unless you're the type who eats cheetos/cheezits at their keyboard).)

2

Coffee. If it doesn't help, a lot of coffee.

Seriously, convince yourself that there's a reward at the end of the task. If it's true, all the better. If it's not, invent something - let your imagination go wild. Range from small stuff like "when I'll finish this I'll treat myself to an ice cream" to "when I'll finish this I'll be more worthy in the eyes of my colleagues and friends". It doesn't even matter if it's a falsehood, you're not after the prize itself but after the thrill of getting there. Once you get the adrenaline flowing, it'll be a breeze (though it might be a 3am in the morning breeze - I've been there).

2

I Sometimes find getting a little momentum can make a big difference. Don't even think about all of the things you need to do to finish but maybe the first, smallest step that you can take in that direction. It could be as small as refactoring a single method or adding a new field to a table. when your done take the next smallest step. At some point the momentum will take over and you'll be roaring along. That's the idea anyway. Good luck

2

I have to agree with Brian in that the quickest way to get rid of programmers block is to just force yourself to start writing something. However, you usually aren't going to be able to force yourself to start working on the code that managed to demotivate you into a block so the best route is to find something you are interested in and work on that for a bit.

While diet and exercise have been mentioned a couple of times, I personally haven't encountered any situations myself where that caused programmers block, excluding any after lunch slow down due to a full stomach. However, good diet and exercise does seem to help get you going in the morning when you first get into the office.

2

When I'm really jammed up, I clean things. If I'm home I wash dishes (even the clean ones) and look out the window. If I'm at work, I clean my desk, wash a few mugs anything to put my mind somewhere else. "It" usually comes to me right about then.

2

Whenever I have the block, I usually realize it's because of 'the elephant in the room' some difficult areas in my project that I know are doable but have not confronted yet; I have not really worked out the algorithms.

The way go round this is to work out the algorithms on a piece of paper in pseudo code until I get rid of all the grey areas. It helps to get away from my desk while doing this, to a café or a library or other such place.

The other solution I would suggest is to try and do a small personal project that is fundamentally different from the project that is giving you the block. The idea is to get yourself coding again.

Another trick that gets me fired up is to talk to someone about the project I am doing. They don?t have to be programmers. This usually brings back all the excitement that made me undertake the project in the first place. After a session like this I can?t wait to get back to my project and code away.

Good luck and happy coding.

2

It sounds like what you're trying to do is trivial so I wouldn't worry too much about planning it out and breaking it down. Instead make a commitment to someone else around what you're trying to get done.

When I'm procrastinating I sometimes just need a bit of external pressure and the feeling that I'm going to let someone other than myself down.

1

It's nice to see that others get this way too. My way of facing this debilitating problem is to write down the task into smaller parts (I usually use backpack.it) and place them in order of time I think it will take. Sometimes the smallest task is something as simple as reformatting text or commenting. These are things which, frankly, I probably wouldn't get the chance to do otherwise. In the process of doing so, I get to thinking about solving an actual problem, or (in the case that I already know the solution) it starts to trivialize the solution that I have to the point where it seems silly to not be implementing it. As I inch just a little closer I find myself working a little bit harder on the next small portion.

1

My suggestion would be to break down what has to get done into manageable pieces and start moving. If your work seems like a huge mountain that can be a bit intimidating and so making a small hill to walk up and down may seem a bit easier to do.

If it is the bug that were working on before and still isn't fixed and you can't see a solution, then that's a different story. After the holiday you may have fresh eyes that can help though I think I'd set a limit on when to have some progress or get help or give the task to someone else to do.

I've generally had programmers block when I didn't know what to do next or when there just seemed like a ton of things to do and each time something got done, there was more to do.

1

Along the lines of health, in addition to diet I would recommend getting up and walking somewhere---preferably not to a distracting coworker's office. I would recommend this light exercise especially during intense work periods or if you are zoning out from information overload (i.e. the web or SO). Some of my best programming ideas were born far from a computer.

1

Choose the most important unimplemented feature. Work on this, and this only, until it is completed. Make sure it is achievable in 1-3 days, if not, break it up. Ignore all other tasks until this one is done.

Write a failing test. Make it pass. Refactor. Run all tests. Commit.

Relentlessly work to reduce the time taken to cycle through this.

Do this in a pair with a colleague.

This really sharpens your focus!

0

The primary reason is usually the laziness, that comes to programmers. I am effected by same.

I drink lots of water, and thus have some exercise walking every one hour, out of my seat and it helps. Sitting at one place, with computer posture for long hours does no good.

Exercise and Relax your mind.