“Why won’t this code work?!”
“I’ve got too much to do and can’t see where I’m going!”
“Ahhh, more deadlines than working unit tests!”
A career, or even a hobby in programming is likely to involve stress. It’s how you deal with the struggles that matters.
The concept of being a mindful coder could trigger all kinds of images in your head; people meditating, doing yoga and praying to the Unix gods.
Don’t worry. We’re not suggesting you lie on your back and flip your legs over your head to create a human laptop stand.
Mindfulness is a type of meditation embracing the practice of being completely present in the current moment.
There are some simple and practical ways to bring calm into your computer-centred world. And if you don’t think you have time, then you are definitely too busy and need to make time for it.
Here are some tips from two top programmers: Gus Savoie, a web developer and visual designer of more than 20 years based in New Brunswick, and Mark Hughes, Co-Founder of education marketplace Tutora.
They both adopted mindful approaches to their working lives to tackle stress.
To paraphrase Gus: “You can re-programme code when it’s not working, and you can re-programme your thinking when it’s not working too.”
Step 1: Pick a good place to work
Not everyone has the luxury of sleep pods, stand-up desks and hammocks in the office. But there are some small things you can do to separate work from life. Here’s Mark with some workspace wisdom:
“Having a space where you work is essential. I’ve met developers who work on a laptop and will work wherever they feel like it in their home and it drives them crazy. The only way they can switch off is by leaving their house!
Make sure that you have a designated area where you work. Make it an enjoyable place to be and reserve the rest of your home for your own time, away from work.”
Step 2: Destroy distractions by focusing on the present
You do your best work when you’re most focused on what you’re doing. That’s a great way to get stuff done in programming. But how do you actively choose what to focus on in such a distraction-filled world?
It’s likely that while reading this article you’ll have emails flying in, never-ending Slack and social media notifications and a mind whirring with financial, family and food related questions.
According to Gus, the trick is to keep breathing:
“So many people unconsciously hold their breath when they are thinking hard like this – less oxygen does not help. Take a moment and check to see if you are holding your breath. Then take a minute and just follow your breath with your attention.
Sometimes it helps to set a reminder to go off periodically. I like to check-in with myself every so often. That is to let my mind’s awareness take stock of things.
Sounds weird, but it can bring you right back to the moment, instead of wherever your mind was off thinking about, caught up in a problem or fantasy. It’s a kind of soft-reset button.
I also remind myself often that I am not building the entirety of my workload right now but I am just building this piece here. Then I will build the next piece and so on – and eventually the whole thing will be done. Makes for lighter work.”
Step 3: Fix errors by putting yourself into the shoes of your functions or methods
Playing the part of an object in object-oriented programming might seem childish, but it’s a quick way to get to the root of a problem. Here’s an example:
If an error message has pointed you to a specific line number but you still can’t see what’s wrong, imagine *you* are the function you are calling. Look either side of yourself; ask what your purpose is and examine whether your code does what you need. To get started, take the role of that function and ask yourself, “What am I doing?”
This role play approach is a fundamental part of the Ruby Monk teachings. Read more here: https://rubymonk.com/learning/books/1-ruby-primer/chapters/6-objects/lessons/35-introduction-to-objects.
Further reading on being a mindful coder:
Mark: “I’ve really determined my own practices over time but my Co-Founder, Scott, swears by meditation app Headspace, which he says always helps to send him off to sleep when his mind is running with thoughts about work.”
Gus: “My primary source of what to do and how to do it was something that tied back into meditation. A little book titled ‘Mindfulness in Plain English’ by Henepola Gunaratana. I still go back to it now and I offer it to anyone who expresses interest in the subject.”