Switching context while keeping your sanity

What is context switching anyway?

Have you ever had days where you had to juggle between multiple projects? No? Well, lucky you I guess but most developers probably know what I'm talking about. If you haven't been in this kind of situation here's what I mean - you're working on project A and then client B calls and says there's something that needs fixing/improving urgently. You put project A on hold and start working on project B. Just as you're finishing up the fixes for project B a pull request comes in and you think "Well, I was done with this project anyway, might as well take a look before going back to A." But turns out there are tons of changes in the PR so you take an hour to go through all of them. After that's done you can go back to working on project A but only for an awkward 45 minutes because a meeting is coming up. Even though that was only a couple of context switches it can easily feel like you went back and forth between things all the time (and yet got nothing significant done!). If this is a one-of kind of a workday then yeah it sucks but if you have to work like this for continuously for a longer period of time the it can easily lead to burnout or worse. So what can you do to avoid going insane?

Avoid context switching

A solid way to avoid mental fatigue from context switching is to not contstantly switch contexts (wow, thanks Einstein!) but how do you do that? Here are a couple of practical tips and tricks:

When context switching is unavoidable

Sometimes the tricks above don't work and you really have to switch between multiple things a day OR when you feel mental fatigue even after avoiding switching as much as possible. Then what?

Meditate

Uuuhh...what? Ok, hear me out. If you've been to a perfume shop you might've seen a jar of coffee beans next to the perfumes. It's there so you can smell the beans between trying different perfumes to "reset" your sense of smell (or as they say, cleanse your palette). Meditating between projects has the same effect but for your brain. But how does it work? Similarily to the smell of coffee being almost a complete opposite of a regular perfume (and thus providing massive contrast between smells), meditating is the polar opposite of working on a (software) project and thus gives your monkey brain[1] time to "cleanse". At this point you may be asking what kind of medidation am I thinking of and for how long? I suggest practicing the easiest meditation there is - concentrate on your breathing. Just be aware of your breathing and if your mind starts wandering around then try to notice it and re-focus on the breathing. As for the duration it's up to you but I suggest starting at 10 minutes. This might seem like a while and a pretty significant amount of time if you meditate between every project but this has a couple of benefits:

If meditating is really not your thing then a great alternative is going for a short walk or a bicycle ride or doing a short workout. Notice how all of these activities are physical (or at least kind of physical in the case of meditation as you're not moving much but still concentrating on a physical thing - breathing). This is intentional as it creates the necessary contrast between projects which are all mental work. That's why it's not a good idea to try to refresh your brain between projects by browsing the internet or playing video games. You're still engaging in a mental activity and thus exhausting your mental resources.

Back to blog