Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Possible Duplicate:
Dealing with frustration when things don't work

Something I find myself coding something difficult and after hours of struggle my mind goes blank and I don't know what I am doing anymore.

I'm not sure if this happen to a lot of programmers. Does this happen to you How do you deal with it?

share|improve this question

marked as duplicate by Thomas Owens, Péter Török, JeffO, Karl Bielefeldt, FrustratedWithFormsDesigner Nov 11 '11 at 14:50

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2  
Taking regular breaks really helps. –  thiton Nov 11 '11 at 14:08
    
I do something completely menial and mindless that requires strenuous effort but little mental capacity. I built a retaining wall around a tree once, another time I built a work bench. Yesterday I built an extension to my firewood rack. For me, the break needs to be significant, not just a 15 minute lapse, and it needs to drain me physically to get my mind to return to an empty state. It happens to me often enough lately that my home improvement projects are really benefiting :) –  Joel Etherton Nov 11 '11 at 15:44
add comment

3 Answers

up vote 5 down vote accepted

As in any creative endeavor, sometimes we programmers get blocked and the creative juices don't flow. A few things that I do when I'm in such a situation:

  1. Get up from my desk for a couple of minutes
  2. Stretch
  3. Start working on something unrelated
  4. Visit the water cooler/chat with co-workers
  5. Ask a colleague for assistance

In all of these situations, I'm attempting to do something that is unrelated to the current task-at-hand. While my foremost activities during this time are unrelated (by design) to what I'm stuck on, my brain is still subconsciously churning away at the problem. Often, the solution will somehow work itself out within the space of a few hours.

share|improve this answer
add comment

Happens to me when I am under pressure, or have been working on the same problem for many days. I have spent days without realizing the obvious solution.

I have found that getting up and walking away is the best way to get rid of it. If you are still stuck, talk to someone; preferably, a junior programmer, or someone who is good at lateral thinking. A second set of eyes always help.

share|improve this answer
    
Hmm, lateral thinking is interesting –  Adel Jan 26 '12 at 12:56
add comment

This happens to everyone. Taking a break, going for a walk, or switching to another project always helps. I have also read about an interesting technique in "Clean Coder" by Robert C. Martin. It is called the "tomato timer" or "pomodoro".

You set a timer for 25 minutes. You can use your phone, an alarm clock, Outlook, etc. In the old days people used a kitchen timer, which would often be in the shape of a tomato, hence the name of the technique. Then you work for 25 minutes without interruption. Don't check your email, don't browse the web, not even StackExchange. If you get interrupted by a phone call or a co-worker, politely ask them to call or come back after the time is up. When the alarm sounds after 25 minutes, take a 5 minute break. Every 4 "tomatos" or so, take a longer break.

Even though this is more of a way to manage distractions, rather than fight programmer's block, it should help with that too. With these regular periods of concentration you get much more done. And with the regular breaks you feel much less tired at the end of the day. I think the breaks are also a way to let your "left brain" (or is it your "right brain"?) work on the problem, which should help you when you are stuck, or even prevent you from getting stuck in the first place.

share|improve this answer
    
Yes, aka Pomodoro , Thank You So Much! –  Adel Jan 26 '12 at 12:56
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.