I have to do some non-coding things. Exercise. Eat. Sleep. I have some leeway on the timing, usually.
Here’s what happens sometimes:
I know exactly what to do next. I haven’t looked at the code, but I can see it in my mind, and the task is clear.
But it’s mid-afternoon — time to go run around the neighborhood. Do I stop right then, or do I do that next thing first?
It used to be that I’d do that next thing. I’d do every single next thing until I ran out of next things, or until I had no choice but to stop.
These days: I put on my running shoes, and leave that next thing for when I get back.
The benefit isn’t so much the self-discipline of it (doing things at the same time every day, which I do like) — it’s knowing that when I return I can get back in the flow quickly and easily, since I have something clear to work on next.
This is a coder’s variation on Hemingway’s advice: “The best way is always to stop when you are going good and when you know what will happen next.”