5 comments

[ 3.1 ms ] story [ 22.0 ms ] thread
One of the rules of Extreme Programming: Quit when you're tired. Go home. Get at good night's sleep. Don't think about work, and don't feel guilty.

If you're in a place that forces you into insane hours for long stretches, start looking for an alternative. When you find a decent one, take it.

From either The Zen of Programming or The Tao of Programming (can't find my copies to narrow it down):

Eat when you are hungry.

Sleep when you are tired.

Program when the time is right.

If I'm feeling miserable about the code, I generally shift gears and work on a more straightforward area of my project. Ideally some class which is self-contained and easier to reason about. More often than not, an hour of that gets me back into "flow" and I can go back to what I was originally doing.
As others have said go do something else if that can happen then switch domains and work on something you consider fun either because you like the domain or the challenge.

Trying to push through with coding doesn't work.

Another trick would be to step out of the editor and hit the white board while on your feet. Programming isn't typing and if you are trying to figure out a problem at the keyboard theres a good chance you already failed (unless your learning the language). Get it on paper/chalk/whiteboard and reason about it, talk about it with someone or a rubber duck.

Take a break from it. Go for a walk. Ride my bike.

Walks in the woods are great for thinking and problem solving.