HACKER Q&A
📣 santy-gegen

How do you code when you're not feeling well?


I find coding to be hard. Particularly, if I'm not having my best day my productivity while coding plummets significantly.

During days like the ones described, I find exercise and breathing exercises help me get back on track but only moderately.

If anybody has better techniques I would like to learn about them. I am grateful for any advice.

All the best, Santy


  👤 chrisdevs Accepted Answer ✓
Let's make a distinction.

If you're sick -> take care of that first. Don't work.

If you're just having an off day, trouble focusing, not feeling in the mood, that's different. I can suggest a few things that's worked for me.

1) Focus on just doing one thing.

Pick your most important project, then pick one specific piece of that, and shut down everything else until you at least complete that.

2) Set a timer.

If you're problem is getting started on a new or challenging project, do something like the pomodoro technique where you just promise yourself you'll work on it for X minutes and then stop. This removes some of the barrier to entry and can help you get started.

3) Remove distractions.

Similar to the first point, but is Slack always on? Are you getting notifications from your phone? Checking e-mail? This is a problem with our current life, we have too much competing for our attention. A lot of what we need to do to be successful is blocking out the noise so we can focus.

Hope this helps!


👤 JohnFen
Are you asking about coding when you're sick?

I don't. When I get sick, I get stupid. If I try to code in those conditions, I'm very likely to just make a big mess of everything. Big picture, I get better productivity and code quality if I stop coding until I have recovered.


👤 h2odragon
My health varies unpredictably; some days I'm not really fit to be out of bed, some days I'm pretty good.

Bad days, if I feel i can try working on something, I tend to stick to smaller "side" parts of a bigger task. Grooming dotfiles, editing docs, that kind of thing. Limit the possible impact of mistakes, and do things more amenable to non-thinking "change and try again" approaches.


👤 aynyc
If you are talking about low energy days, my trick is to write documentation and unit tests. They don't require a lot mental focus, failure has limited impact. This is a trick I've taught to other juniors over the years.

👤 dyingkneepad
Those are the days where you clean up all your email backlog, do mandatory yearly corporate BS training, update status reports, clean up Jira, etc. I also find that on those days, root-causing bugs is easier than trying to actually write code (that either fixes problems or creates new features).

👤 codingdave
I don't. I learned long ago to code when I am feeling like coding, and not code otherwise. This is why I am an advocate of coders having flexible work schedules - sometimes you just aren't feeling it, but you can make up for that when you are.

👤 obahareth
For me, I recently got into drinking Yerba Mate (unsmoked, traditional way) and it's made me able to stay productive even in bad days.

Not really a technique, but something that worked for me.

EDIT: This is for when I'm feeling unproductive/down, not when I am feeling ill. The best thing for illness is rest and the right meds and nutrition.


👤 LarryMade2
When you aren't up to coding do review of what you have written, make notes on corrections needed as well as any ideas for improvement.

Good time to review user experience from your diminished perspective.


👤 luhego
I just take a shower and go to sleep. Sleeping makes me feel way better and usually I can code better after that.

👤 fullstick
My first manager out of college told me "you can't always perform at 100%, it's okay to have off days". That's gotten me through a lot of meh days at work.

I usually just try again tomorrow when I can't get anything done. Or I try at 5pm and work later than usual because I didn't do anything all day lol.