It also lets me just ignore people who interrupt me during one with a quick "I'm busy, I'll be with you in (X<25)" or "Ask me in (X<25)". Sometimes the response they get during that break-time convo is that I'll get back to them even later, I need to think about it.
But it's surprising how quickly people will pick up that if they bother you on the hour or half past, you'll respond and othertimes you'll blow them off.
For now I have:
- write down everything: tasks, discussions & conclusions, etc (you said "keep a backlog of tasks")
- when interrupted while coding, insert a //TODO with a few words that will help rebuild context on resuming, maybe with a statement that does not compile to quickly get back there (if the interruption leads you to navigate away from that file/editor)
- if a few seconds are not enough, explain "I need a few minutes to write down stuff and I'll get back to you". This is always accepted without issue. Although it's difficult when the person politely waits behind you :)
- if you figure you really cannot be interrupted on the spot, make great effort to explain this as gently as possible, and offer to get back to them later: again, always accepted by peers (in my experience). If the interaction stays below a few seconds, AND I stayed agreeable & polite, I have little problem getting back in the flow. When I reply too curtly or let the slightest trace of anger show, then I fail to get back in, because my thoughts are polluted with remorse & guilt.
- over time, learn to identify in advance when you are about to enter a "really-really-no-interrupt zone", and then wear audio gear or something to signal this. And don't do it too often.
- I also noticed "recursive tasks" are a challenge. You suggest to avoid them when they are just ideas that help the previous task, but what if they are impediments that MUST be fixed? (Google "malcolm hal fixing light bulb" for hilarious illustration). For this I only have "write down everything", but it gets frustrating with the feeling I'm getting slow due to constant swapping, and could be faster if I could count on short term memory alone (and no interruptions...).
Anwyay... would love to read more about "embrace interruptions" & "optimize for re-starting".
I'd argue the closest profession would be lawyers. Lawyerese casts "variables" (collective) all the time and you need to remember what each collective means while reading through a verbose document that could span multiple pages and references itself constantly (see the exceptions listed in §2.7 and §4.2b). You have to keep the entire document in your mind at a single time to actually be able to read and understand it properly.
The "layperson" understands not to interrupt a lawyer they see reading through a stack of 100 pages on their desk. They don't understand not to interrupt the coder who has 12 lines of code open in their IDE.
Seeds of truth often grow cargo cults of self importance around them.
If you can't get back to coding productively after an interruption, it probably means that your code or your process isn't really up to snuff (or more charitably, that it could be improved).
I try (and do not always succeed) in coding like this, privileging tiny changes, keeping a backlog of tasks to complete, avoiding "recursive tasks" (starting a task in the middle of another because it would help), putting in a lot of helpful comments. It also entails refactoring early and often, sometimes rewriting.
I work on highly sophisticated programs (compilers) and if I didn't do that, I'd get nothing done.
I also do this for my side-project. I optimize them for "re-starting". When I open them after a few weeks of inactivity, I don't want to get discouraged, and want to be able to start being productive as fast as possible.