I’ve also learned to write code in a way that reduces cognitive load so that interruptions aren’t so disruptive to my productivity.
I have too, but sometimes I have to read other people's code, and I don't have any control over how difficult that is.