views:

1145

answers:

16

I know this is the sort of somewhat open-ended question that we're discouraged from asking, but there are lots of open-ended questions around already, and this is something quite relevant to me right now.

Do you ever get those times when you're about to start work on a new function/feature of an established system, and you get "coder's block"?. It's like a mental freeze at the sight of a large, completely unpopulated dialog, or an empty code file with just the stub reference headers etc. Do you ever have that 'ulp' moment that seems to sap all your momentum and leave you wide open to distractions (surfing the web for inspiration, checking out 'crackoverflow' etc)?

Not that I'd wish it on anyone, but hopefully some of you do, and hopefully some of you can suggest tips or strategies for overcoming the situation, regaining your momentum and becoming productive again.

I usually try to reduce what I'm about to do down to absurdly small steps, in the hope that as the job becomes just a series of 'doh' tasks, I'll kickstart myself into working through them. However sometimes, particularly when a deadline is looming, I'll get overwhelmed by this approach as I realise I probably don't have enough time to do all of those tiny steps properly. Those are the darkest moments, (often literally) just before dawn!

This situation can be particularly crippling if you mostly work alone, too.

Any thoughts or suggestions? Any methods that you found helpful yourself?

+7  A: 

Write a brief bit of imaginary code that calls or interacts with the block of code you're about to write.

Doesn't even have to be a unit test -- I find that seeing "client code" before writing the actual implementation helps focus my mind.

kamens
+26  A: 

I think we all experience this from time to time. This normally a good sign of one/more of the following (for me at least):

  1. You need to take a break, grab a coffee and get away from it. Grab Coffee!
  2. You dont fully understand what you are trying to do (i.e. why design a form/class if you don't know what you want to do with it?). Stop, go back to your design, TALK/WALK yourself through what you want the form/class to do.
  3. Your design is kinda screwy and you are trying to mentally "put the square block in the circle hole". Stop, see step 2, why are you doing this? Do you need to refactor?
  4. Good 'ol fashioned stress, your worrying yourself so you can't think. Get away from it, listen to a relaxation CD or something for 5 mins. Break your tasks down into smaller, manageable tasks that you can DEAL with.

I'm sure I have some good links on this, I will have a dig and may edit :)

EDIT

There are many, mant GREAT articles on organization and productivity on Stepcase Lifehack, I strongly recommend adding it to your RSS and checking out some of the artcles on project management, GTD and keeping the noggin' fresh :)

Rob Cooper
+2  A: 

First do all the things Rob and kamens said.

If that still doesn't work then.

Think about where you need to go. what does "finished" look like? Lot's of the time I'm stuck it's because I only have a hazy picture of "finished." If you're not sure then find out.

Think what the first thing is you need to do to get a bit closer to finished. Planning the whole thing is usually not yet possible but you can get a bit closer.

Repeat.

Mendelt
+5  A: 

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.

Brian Leahy
+21  A: 

Rather than writing junk code or throwaway code, why not start writing some unit tests?

It's a great way to get you moving. A unit test is usually a much easier to get started on than the main code itself and forces you to break down exactly what it is you are trying to do. Then it becomes very easy to write your actual code because you are writing it against some very clear tests so know which way your are headed. You can now see the forest for the trees.

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

reefnet_alex
+3  A: 

I've certainly experienced this - Interestingly much less so if I had a spec to follow. Somehow, when what you need to achieve is written down, it's much easier to pick the easiest bit of it, and get started.

I'm guessing the paralysis comes from having too many possible things to do, and not wanting to forget any of them. Once they're out of your head and on paper, you can start anywhere without fear of forgetting anything.

Matt Sheppard
+1  A: 

I try and start by doing the simplest, easiest thing possible. Whether that's laying out items in a dialog, writing function stubs or just creating the getters/setters that I'll need for the class variable.

Normally once I've done these things I'm easily able to carry on with the other things that I was procrastining/worrying about.

Matt Warren
A: 

I'm getting coder's block every time I start coding everyday. Like, I don't know what to do and I don't know where to start. I have to start reading some couple of codes for the momentum.

sasayins
A: 

Coding is an act of translating complicated business/functional requirements into step-by-step computer instructions.

For example, everyone knows what Tetris does, but if you ask someone to write a spec, he/she may not know where to start. For example, someone may forget to mention that the blocks fall down periodically, or that the velocity increases as the player's level goes up.

One way to break things down and discover hidden requirements is to verbally talk to someone what you are doing, preferably off your desk. Bring a piece of paper if it's going to be complicated or drawing diagram helps.

Once you've identified the key nouns/metaphors, you're halfway there to write your class.

eed3si9n
A: 

Ask yourself, what's the first thing I need to do to progress this? Don't try and work out every step, just work out what you need to do next.

Sam Hasler
A: 

For me, it depends on how I'm doing it. 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

As for an empty form: draw it on a whiteboard/paper first!! there is no reason to have a blank for in Vs.NET/tool-of-choice - you should have designed the flow, most of the layout (even if it's just "this form as name, address, age, ok, cancel") etc before you even OPEN VS.NET.

But standing back, thinking about it, is a good idea.

Nic Wise
+1  A: 

Like for many others, GTD/TDD -style works for me. Pick something simple that you're 100% sure you can do (like designing the naivest possible interface) and start thinking about what you need to do next.

Hirvox
+1  A: 

If you are experiencing the Coder's Block, then you actually don't believe that your project will earn millions of dollars so you won't need to work anymore.

Switch to another idea that can earn millions of dollars.

bmm
Maybe I'm working on something for love, or for the greater benefit of mankind, or just because it's a problem I want to help other people to solve even if I will never receive any financial reward or recognition for my efforts? :-)
robsoft
Yea you are right :)
bmm
A: 

PUT THE LOTION IN THE BASKET!

caticus_attackus
A: 

my friend is going through this..he doesn't know from where to start

sack
A: 

Personally I find there's two kinds of programming tasks. There's the challenging and interesting tasks where you're not quite sure on how to accomplish your goal. These are usually not a problem since they're fun to work on an try try to come up with a solution to so you often reach flow state while doing them.

Then there's the tasks where you know pretty much exactly how to accomplish it and it's just a matter of putting fingers to the keyboard. These tend to be pretty boring and has a higher chance of leading to codersblock. It's like homework when you where in school in some subject you didnt find interesting.

One option is simply do dig in and just do it. I've found however that another good method is "tricking" yourself by listening to some interesting podcast/audiobook/documentary while doing the task. It will keep you working and away from pleasuresurfing, try it!

MattiasK