DEV Community 👩‍💻👨‍💻

Cover image for Mindful coding
Jason Leow ~ golifelog.com
Jason Leow ~ golifelog.com

Posted on

Mindful coding

In the first few months of coding, I noticed a bad coding habit starting to emerge. I call it zombie mode.

Usually it starts when I hit an error, and I jump right into troubleshooting it. I google for the error message, and browse through the results and start to fall into a rabbit hole of the internet. After the third or fourth results, my eyes start to glaze over. My brain start to turn to mush, exhibiting signs of information overload. Classic cognitive overwhelm.

And I just sit there flipping through web page after web page, really determined to solve the problem, yet not really thinking clearly to hunt down the right answer, but just kind of mindlessly consuming and being bounced around different answers while in this “zombie mode”. It’s not the best for productivity, and it’s mentally draining.

The funny thing is, sometimes I get up to go to the bathroom or have a water break by happenstance, and usually that’s when some small breakthrough will bubble up in my head. Or it might happen when I’m rubberducking – writing down the issue to ask for help on a forum or from friends. The point is, whatever that gets me out of mindlessness back into a state of being alert and mindful, is usually the breakthrough. And that’s great because now I get to apply some of the mindfulness practice techniques I use in daily life, to coding.

That got me brainstorming a bit... What can I do to be more mindful while coding? Some ideas that came up:

🚰 The longer my coding session runs, the harder I should be practising mindfulness. Because any bug that takes more than 30min will start to tire me out, so I should start taking attention breaks to think clearly rather than continuing to burrow down head-first. I should be approaching it like short intense sprints of hard, clear thinking, rather than a marathon of low to moderate mental effort. So water breaks, bathroom breaks on timer when coding.

⏲ Use a timer to introduce hard attention breaks into the screen. I use a Mac menu bar app called Tadama, that blanks out the screen with a 30s countdown timers every 30min. For a while now I kept turning it off as it felt distracting (especially when writing), but maybe when I start any coding I should toggle it back on to help me break out of zombie mode should I fall into it unknowingly.

📝 Sketch it down, write it on paper or type out the issue as I would when asking someone else for help. That brings my mind back to a state of meta-cognition and observer mode, so that I can think clearer.

📋 List out the questions I have about the error and the results that come up, and be methodical in searching for each one by going down the list (instead of randomly bouncing around web pages).

Any other suggestions for mindful coding?


Follow my daily writings on Lifelog, where I write about learning to code, goals, productivity, indie hacking and tech for good.

Top comments (7)

Collapse
napmi profile image
Eric Heng

I too fall under the same disease. I just keep digging the hole I'm in deeper, or stay drowned until the last moment where I reach out for help. And suddenly WHAM! I explain my own solution to my problem and I go and try it out. You know the outcome.

Collapse
jasonleowsg profile image
Jason Leow ~ golifelog.com Author

100% can relate! So what do you do now to overcome this?

Collapse
napmi profile image
Eric Heng

I just learn that when working with teammates, I just need to borrow their minds a moment and bounce ideas or explain problems that i may or may not understand.

Keep trying with different people, until you have to put this issue on a backburner and bargain for a simpler solution. Then you call it V1 :p

Thread Thread
jasonleowsg profile image
Jason Leow ~ golifelog.com Author

Ah yes, that's the nice part working in a team. I work mostly alone, so I tend to message my coding friends for help too.

Collapse
aliasblossom profile image
aliasblossom

Yes - I have started to use an app called TimeOut for Mac. It actually locks me out, and I have the defaults enabled. I use the quick break to look across the room, get something to drink, or pet a cat.

Collapse
jeffsvic profile image
Jeff Svicarovich

Thanks for the tips. For me normally some exercise can help me get my focus back.

Collapse
jasonleowsg profile image
Jason Leow ~ golifelog.com Author

Yes, that's another great hack. Nothing like getting some blood running to the brain to trigger new solutions!

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.