After several extremely productive days this week; this morning I fired up my IDE’s and opened up the code-lines I am currently working with. I cracked my knuckles and then …… nothing. I am actually really excited about my projects and their progress too. Whether you call it “programmer’s block” or “lack of inspiration”, we all hit a wall occasionally. I tried stepping out of the office for fresh air. I grabbed a cup of coffee. Nevertheless, I fear this day could quickly devolve into scanning for my favorite old Onion articles.

So, I am wondering, what do you do to regain your coding motivation?

Note: I understand this is a rather subjective question, but I think the highest rated answer should be kept and perhaps in the future when this is indexed it could save an uninspired developer from losing a work-day to browsing ‘the online’.

+4  A: 

I walk away. Maybe not physically, but I get as far away from the problem as I can for 5-15 minutes. I come here, I browse Wikipedia, I read my RSS feed subscriptions, I might go talk to a co-worker who isn't busy at the moment (if I can find one). Anything that gets me away from the code and clears my head helps me out.

Thomas Owens
Have you tried not to think? That's like a 'Next level' of what you are doing already.
Arnis L.
+27  A: 

Exercise. It releases endorphins and relieves stress. Sometimes that's all it takes to overcome a case of programmer's block.

Kevin Pang
I just thought of that one scrubs scene, where Cox tells Turk to play four finger against willy to prepare for the surgery "It releases endorphines and relieves stress"
I can't program after exercising. Yes, it relieves the stress, but I can't summon enough energy into my brain to get into a programming zone.
hasen j
I think it's more about exercising regularly as it helps your mind stay sharper throughout the day. I could be wrong, though.
I could not agree more. Excercise => Productivity, and that's often as satisfying or better than looking good, too.
Andres Jaan Tack
+16  A: 

A technique I often use is to start working on something in the project that I personally thought should go in, but might have been cut from that release. Since it's something that I wanted in the first place, it is likely to hold my interest and will hopefully respark my interest and inspiration in the rest of the project which actually need to be worked on.

Note: Make sure you keep these "new features" on your machine only otherwise you might get someone annoyed for going behind their back and doing what you were told not to. I'm just talking about banging away at some related code that you find interesting for 20-30 minutes and then trying to segue into the real code.

Adam Haile
+2  A: 

I agree with Thomas, getting far away generally does work. Sometimes, though I find working on an unrelated bit of code or a different problem (math puzzles, IQ tests etc) gets me fired up.

..I also like eating and thinking about food, but that could just be me...

If embedded in a large project, I also find that looking at other people's work or helping other people with problem (such as those here on SO) can really help too.

Gareth Jenkins
+1  A: 

I usually just put down what I am supposed to do and then do something completely unrelated. I find GDI works great for this. After a while you usually have something pretty on the screen and can go back to your code.

The bigger question is why you lost motivation in the first place. Understanding that will help greatly. I usually find that it happens due to the scope of the project. In that case I break it down into smaller chunks and start on those, smaller, chunks. Usually works great.

Good luck!

PS: But, really, can you beat going outdside on a nice summer day... :)

PPS: goofing on Stackoverflow!!

+14  A: 

I keep a ton of books about work-related technologies and a few new things at my desk. When I find I can't bring myself to work on "real work", I go into research mode and study a topic I find more interesting until I get motivated to work on that. This way, even though I'm not necessarily getting my tasks completed, I'm at least learning some things that will help me out on future tasks.

+2  A: 

Force yourself to start working on some part of it. A part that doesn't really require too much thinking. Reformat code, update some documentation, write in the project wiki, etc. something really easy then you can gradually work your way back into "the flow".


@Adam Haile: I created a folder under my "sandbox" directory and created a new small project to toy with a concept that was cut from the spec in a secluded environment. Then I came back here, refreshed the browser and saw your comment. It kind of ties into OwenP's point too, but I think those are both great ideas!!

Ian Patrick Hughes
+3  A: 

I find music can really help. Just go for a walk with your iPod, listen to seem really great songs that take you away from the programming and come back renewed.

Beyond that I'd suggest working on a couple of problems related to the project that you haven't had a chance to look at in depth, i.e. (if you're a .net dev) you sort of worked out how to make LINQ do the thing you wanted it to, but you don't fully have a deeper understanding. You should go off, create a fresh project and just explore LINQ in depth for a while. I find the satisfaction of a deeper understanding of an area really helps motivation big time.

I could not code at ALL without music!
+1  A: 

I usually got a few things on my plate at any given time...I'll usually pick up something else to work on for a little while then go back to it. The shift in mental power is enough to make it feel fresh when you come back to it.

+4  A: 

@Ian PH

I created a folder under my "sandbox" directory and created a new small project to toy with a concept that was cut from the spec in a secluded environment. Then I came back here, refreshed the browser and saw your comment

Nice. I actually do this all the time and it has benefited me on numerous occasions. For example, times when the boss comes over and says "remember that feature you wanted? Could you prototype that?" Coming back to them the next morning with a full-up demo can make you look really good. It basically gives me a bunch of features I can pull out at any moment, polish up, and save the day...or whatever :P

Note: Showing it to them later on is key. For one, if you said oh sure, here it is, they might not like that you were doing "unsanctioned" work. But also, as it's obviously something that didn't get your full attention, this gives you an opportunity to test, check and generally polish the code and design so it doesn't blow up when your boss is using it.

Adam Haile
+5  A: 

This "coder's block" may just be the code telling you that something is wrong with it. Your design, or algorithm, or the entire approach you're using to solve the problem no longer "flows".

Walking away helps, but when you come back, try to do whatever you're doing in a different way.

+1  A: 

Some days are simply not going to be as productive as others. I find that after several days of intense work on a project, I need some time (maybe a day or two) to unwind. On those days, I try to do some planning for future projects or explore new technologies that I may want to learn more about. Frankly, I don't think it's healthy to feverishly attempt to maximize accomplishment every single day.


@Adam Haile:

Nice. I actually do this all the time and it has benefited me on numerous occasions.

It almost always pays off, too.

After seeing Joel demo FogBugz here in San Francisco when he was on his "world tour", I really loved the diffing views in the wikie and started thinking heavily about approaches to diffing algorithms. Decided to code a little project and tucked that nugget away.

A few months later the request came down the pipeline: "Is there a way we could we compare changes to articles in our publishing system?"

"Sure, let me look into that." :)

Ian Patrick Hughes
+7  A: 

I can suggest some method called Natural Planning Technique from David Allens book Getting Things Done. There are 5 Phases to do this:

  1. defining purpose and principles
  2. outcome visioning
  3. brainstorming
  4. organizing
  5. identifying next actions

So you are rolling your work up from the end. For me the key to stay focused and motivated is the second point. Close your eyes and try to figure out what wild success would look, sound, taste and feel like? After that start with an action that will lead you a step further to your preferred end game.

In the most cases this helps me to get back into the flow. And if nothing helps, grab a beer and skip the rest of the day with browsing stackoverflow :-).

Peter Hoffmann
+2  A: 

I find myself a really really good sleep.

And then I force myself to code straight for as long as I can and in as quiet an environment as I can until I can get in to "the zone".

I just forced myself into it. I get in to "the zone" eventually most of the times.

Changing areas of work help too, say if you're bored of maintenance, think up of some crazy new features and go implement some support for it. Then when you're in "the zone", go back to that maintenance work.



Your design, or algorithm, or the entire approach you're using to solve the problem no longer "flows".


Ok, just kidding about that. :)

Seriously though, it's not that kind of block that I am addressing here. Honestly, the project and code is great. It's more along the lines of just that all around "meuh" feeling. I tend to find if you push yourself when you feel that way, you can actually write bad code that someone (probably yourself) will have to fix eventually. You're probably best walking away for a bit as many answers here so far elude to.

Ian Patrick Hughes

I find myself a really really good sleep.

Chakrit, I think you are onto something there. When I had the flexibility of a 3 or 4 day workweek, that was my method. Get rested-up and then just explode. Man, I am missing "the zone" so bad today too. You know those occasions when you're coding through a gritty routine and it's just coming out beautiful and you feel a smile slowly start to creep across your face?

Ahhhh. Good times.

Ian Patrick Hughes
+1  A: 


Totally agreed. :-D

Just find a way to fit that into whatever your work env. you are in now.

Or go freelance

p.s. just kidding :-P

+2  A: 

David Seah's Printable CEO has a lot of resources you can print off to help you keep you motivated.

Sam Hasler
+4  A: 

I plow through. Before I leave / turn off the monitor the day before I write down three things I need to do the next day. Usually 2 are part of the code. 1 is a person interaction that needs to be done related to the code. When I get in, in the morning I just start cranking on that list. The quicker I get through it the quicker I can map out what to do the next day. If I get stuck on one of the code points I'll hit up the personal angle in an effort to move away from the computer and let my brain "rest".

edt: Also you let your brain work on the 3 items in its subconscious over night. Or when you are stuck at that light going into work. It helps lessen the friction when you get in.

Chad Boyer
+3  A: 

I've planning the day in 20 minute chunks (and then crossing things off the list) to be quite helpful, it gives you a feeling of progression in an otherwise hard to measure process.

Steve French
+4  A: 

I experience this a lot, as I do a lot of documentation for code. Eventually you grind to an immediate halt and for no love nor money can you continue.

It's most likely just a result of your brain stopping you from overworking yourself. Let's face it, the human race was not built for intensive thought-labour. We were given our physical bodies for a reason and us programmers neglect them on a daily basis.

A bit of back story here: I suffered a pretty nasty accident almost two years ago that resulted in me not being able to walk for 12-16 weeks. As I was unable to move around I was stuck in a bed with a laptop and a mountain of books, so I done what most geeks would do, read about Computer Science and Maths and write some code. After a couple of programs my mind just froze and it would take a lot of rest before I could carry on. Eventually as I started physiotherapy my programming abilities started to strengthen, because I then had the ability to get away from a computer and do some 'exercise', even if it was learning how to climb stairs again.

The point that I am trying to make is that your brain is obviously tired and that you need to get out and work your muscles. I joined a gym recently so I spend a couple of hours three times a week there working on rehabilitation.

After a couple of thousand metres on the rowing machines you'll be itching to get back to your computer.

+7  A: 

Temporarily lowering your ambition level might help. I think motivation works similarly to car gears. In order to start moving you need to shift to the first gear, set really simple goals, and wait for your motivation to go up. For example when programming "full automated physically driven ragdoll animation system" start by creating a program that multiplies two quaternions and draws resulted rotation in a form of a rotating line. Even with such a simple task you will feel like a king of the world after implementing it. Then you will be ready to do more. But only during that day. Next day your motivation "velocity" will be zero again, and you will have to start all over.

  1. Jump on Stack Overflow and answer some questions.
  2. Take a walk around your office.
  3. Chat with people in your area
  4. Procrastinate just a little, so you'll be forced into being interested to get the job done.
Procrastination is the problem, not the solution.
Tadeusz A. Kadłubowski

I prefer walking outside when my work stops. Also, as I always have some ideas I'm going to implement in next sprint, they are tested in little projects and then included in the application's code. And there is motivation wallpaper from Matt Shelton on my desktop. So the only thing I have to do is minimize all my windows.


Usually, the key is to set a rather simple goal of what will I do within the next hour for example and get that done so that I feel that I have moved from where I was before. Another thing is to switch to another task as sometimes one can only take so much of one project before wanting to go find something else to do.

JB King
+1  A: 

First off - don't give yourself a hard time about it, feeling guilty is the worst thing you can do, praise yourself for the achievements you have made already and the skills you have. To get yourself going again often requires creeping up on yourself from behind and not going at it logger headers.

Is this just a one off or a pattern? If it is a one off, don't worry, consider:

  • taking the day off in preparation for tomorrow.
  • doing the house keeping, admin, tax return, expenses, ect.
  • Get a sounding board for your work
  • Make social contact
  • go for a walk
  • indulge in your hobby

If it is pattern then you need to take more serious action. Working well for long periods of time requires that you balance your life carefully. Look at this list of "life activities" and mark each one out of ten as to how satisfied you are with them in your life A. over the last month, B. Over the last year:

  1. Doing something creative
  2. Being in nature (walks, gardening, etc)
  3. Your "significant other" relationship
  4. Your friendships and extended family
  5. Your sex life
  6. What you are doing for work (for income)
  7. Excerise
  8. Time with kids (if you have them)
  9. Finances

Now think about your short and long term goals for addressing the items with lower numbers. Print them on big on a sheet of paper and stick them on the wall.


What I find works for me, is to look at other people's work (online, or in magazines). Sometimes in postmortems. Since I work with graphics, I find looking at new games coming out or looking at other people's graphical work tends to motivate me to get back on the horse and start making some quality code.


Unplug the ethernet cable, disable the wireless adapter ... whatever it takes to get disconnected. Generally if I am distracted, it is because I have jumped into some new interest that I must research online right now. Make sure you have all the docs you need offline. Most of us do, yet we jump to Google anyway, and who knows where we may end up after that. :)

James M.

At work, my biggest motivation comes from the fear of not accomplishing something for the next day's morning stand-up meeting. So around 3:00pm I realize my back's getting closer to the wall and I start slinging code so I can get out of there by 5:00pm to go work on personal projects.


From a recent Coding Horror post:

RSA Animate - Drive: The surprising truth about what motivates us


Daniel Landi