WTF is Context Switching And How Do I Avoid it as a Developer
It’s 11:25 am and I’m in a flow state. I’ve been hyper-focused, listening to Audiomachine on Spotify, and killing it for the past hour. I still have a few more hours to finally put this feature I’ve been coding to rest before I can move on to the next project. I’m a bit ahead of schedule until…
Queue The Interruption
Someone knocks on the door to my office. I’m pretty certain they know that I’m in DND mode (Do Not Disturb) because I set my status on Teams to DND and put a DND sign on my door, but I forgot to lock my door. CRAP!!!
I have been completely derailed from my flow state and interrupted by someone ignoring my need to focus. They walk in and start asking about a feature I just deployed to a feature branch server two days ago and now need me to make a change that just came up. I know and they know that the change will take about 15 minutes and me being the nice guy, I tell them I’ll get it deployed to the feature branch server in 20 minutes.
Getting Focused
I stash my current code in a different branch, make the change requested, deploy it, and switch back to my project. It takes me about 20 minutes to get back to some kind of focus and by that time it’s time for standup. I eventually get back to work after standup and lunch. I don’t achieve a flow state, but I’m a bit focused until… yeah, it happened again and I forgot to lock my door after lunch.
What The F***???
This happens all the time. You’re working on something specific when you’re tasked to work on something else you coded days or even weeks ago and it takes a while to remember what the hell you or someone else wrote and how to implement the new change. Then, you go back to your original task and it takes upwards of 30 minutes (sometimes longer) to get back on track with that really complex ultra-scalable, and extremely performant code.
This is Called ‘Context Switching’
Context switching, in computers, is essentially when the processor pauses the execution of a task to execute another task before switching back. Now that computers have multi-core processors and programs can be run on multiple threads, it will look like the computer is working just fine. Humans are not computers, no matter what my wife thinks of me. We are not able to quickly context switch and pick up where we left off with the state of the task in our heads. We lose track of what we were working on.
Non-developers will not understand why you’re taking longer to finish something that you were already working on. They think that you just had a break in your work to work on something else for about an hour; that in their minds might be a reprieve and that you needed it to be even more productive. I call bullshit and you should too.
Context switching is a productivity killer and your team and upper management need to be aware of it and respect your focus time. Multiple instances of this can reduce your productivity by 30 minutes to an hour each time. If you get interrupted 2–3 times in a day, that could be 1.5 to 3 hours.
How to Address It
You’ve already read what I tried to do earlier. Turn off Teams, close Outlook, block the day in Outlook as busy, close and lock your door, and put up a DND sign. If you have the option of working from home, do that and make sure no one at home bothers you. At my company, we will send an email to everyone indicating that we will be focusing on something that we won’t answer any messages or emails.
Luckily, the owner of the company and the VP understand that we, as developers, require focused time to get these features done on time. Unless it’s an emergency, we are not to be bothered. However; you may still get someone not sticking to the rules of focused time. Address the situation as you see fit and make the person aware that you can’t be switching tasks that day.
Unfortunately for me, the interruptions I had were for a release that was scheduled for later that week and I was the developer that understood that area of the application.
Make sure you educate your team and managers on context switching and the importance of focused work.