4 factors that commonly affect programmer's ability to focus at work

adminguy's picture
Posted December 23rd, 2015 by adminguy


Even though we have automated many mundane and time consuming tasks like laundry, bills, and have access to quicker communication with emails and messaging apps, we still find ourselves overworked, stressed, tired and feel out of balance in our lives. While we may blame deadlines, relationships, traffic and whatnot for our problems, an often overlooked factor may hold the key to our lack of happiness. In a time of continuous partial attention it has almost become uncool to focus on one-thing-at-a-time, but it may be that one magic factor which can change a lot for the better.
There's a very interesting TED Talk by Matt Killingsworth which links mind-wandering to unhappiness and another TED Talk by Mihaly Csikszentmihalyi on how being in a state of flow can foster happiness. Avoiding mind wandering is akin to mindfulness which not only makes us happier but also improves performance.
As developers we often don't appreciate the extent to which multitasking harms us and our projects. When we multi-task, our brain is not focusing 100% on the code which we are writing. This means there is a huge probability of writing buggy code. In his book Code Complete, Steve McConnell says that the industry average of bugs is about 15 - 50 per 1000 lines of code. I suspect lack of focus is one the reasons for such a high number.
Lack of focus can also exhaust the brain. Scientists have also started noticing the damage that lack of attention does to our brains. On the other hand attention training techniques actually do a whole lot of good to our brains. So which one would you choose? Focus, better brains, more peace, more satisfaction at work well done or the lack of all of these?

There are many reasons why we lose focus. What gets me to lose my focus may be different from what affects others. I'll discuss some of the most common factors and how to deal with them.
Emails, cellphones, instant messages
I know people who check their email once every hour and some who do it only three times a day. Each person will probably have a schedule that works best for them. The only golden rule here is - don't let your emails do the driving, you drive the mails. Ditto for cellphones. The only calls I answer when I am in the middle of important work are the calls from my family (or someone who I am expecting to call me) - the rest of the calls get replied back after lunch or while having snacks or after the workday. As far as instant messages are concerned, I make frequent use of the busy status. When I am trying to focus on something I set my status to busy and set it back to available once I am done with my focus time.
Social networks
I did not include social networks in the previous section because they are a menace in their own right and deserve a separate mention. I am glad that teenagers are moving away from certain social networks, and I hope they do not latch on to other equally or more destructive ones. If they find the will to not be swept in the stream of their timeliness, the next generation's workplace will have fewer productivity issues. But I digress - we are not teenagers and in any case they have other issues of their own. Coming back to dealing with social networks, I have learned to follow advise from a wise friend of mine. He never checks any social network timelines while at work. Period. All status updates, likes, retweets, plusses, all of that happens after work hours. I have found this to be the simplest and most effective way of dealing with the time and attention drain that inevitably happens the moment you take as much as a glance at your timeline.
Noise in the office
I agree with Joel Spolsky when he says that programmers need quite time to work, and that happens best in cabins (with doors). However, I have rarely had the good fortune to have my own cabin (with a door) and I am willing to bet against huge odds that you too are in the same boat. Perhaps headphones were made for people like us. Many developers I know swear by low volume instrumental music playing while working. Some people prefer to have what is known as white noise because it drowns out the background noise of the office, while others prefer to use noise canceling headphones. I use headphones with low volume instrumental music to be very effective, but your mileage may vary. I encourage you to try out each option and find out what works for you. Noise canceling headphones can be pretty expensive, so you might want to try them the last. 
Deal with our own internal chatter
In his book Focus, Daniel Goleman warns us of the peril of our internal chatter. He says
It’s not the chatter of people around us that is the most powerful distractor, but rather the chatter of our own minds. Utter concentration demands these inner voices be stilled. Start to subtract sevens successively from 100 and, if you keep your focus on the task, your chatter zone goes quiet. - Focus by Daniel Goleman
So what should we do to pacify this inner voice? The best suggestion experts have at the moment is meditation and mindfulness. Regular practice of meditation is very powerful and can actually rewire the brain, bringing with it lots of benefits, including the benefit to reduce (and over a long time even stop) the internal chatter.
Focus is a timeless gem
In this article I have discussed some of the most generic reasons that make us lose focus. Next week I'll discuss a few more factors (which are more variable) that can also have a profound impact on how well we are able to concentrate. In the meanwhile I'll leave you with a timeless gem from William James:
“…whether the attention come by grace of genius or dint of will, the longer one does attend to a topic the more mastery of it one has. And the faculty of voluntarily bringing back a wandering attention over and over again is the very root of judgment, character, and will. […] And education which should improve this faculty would be the education par excellence.” - William James (Writing 1878 - 1899)