According to Edwin Bliss
Amount of time spent on a project is not what counts: it’s the amount of uninterrupted time.
One of the most prolific of modern novelists was […] Georges Simeon. [His] method was to cut himself off completely from the outside world while working on a book: no phone calls, no visitors, no newspaper, no mail; living, as he said, ‘like a monk’. After about eleven days of total immersion in his writing he would emerge with another best-selling novel.
Few of us would carry concentration to that extreme – but what if we did, who knows what we might accomplish.
Stephen B. Jenkins wrote an excellent article (with a boring title) called “Concerning Interruptions” on the huge cost of interruptions to the productivity of computer programmers and gave practical advice on how to reduce that cost. (Strongly recommended read.)
For the historical context, a good source is Christine Rosen’s “The Myth of Multitasking“.
On longer time scales, when you must drop something for a while, it’s important, before doing so, to leave behind enough context for yourself to swap it back in. Write down some organized notes about where you were, what still needed to be done, etc. Keeping a log can be a big help, too, but it’s not a substitute for a high-level summary before suspending the task.
(For programming in particular, when you consider that you will need to revisit most computer code someday in the future, this is also a selfish reason to build a legacy of great comments and documentation.)
A good mental model for suspending a task is to leave behind the sort of information that you would need to hand it off to another person to finish.
Pretend that you are handing off the task to another person and you will be going away on a long vacation and unavailable to answer further questions, because when you come back to the task you will effectively be that other person.
Swapping in a new context is very expensive. Saving your state well when you suspend is actually much, much cheaper overall, assuming that you’ll need to come back to the task eventually.
This is one reason it’s important to write your to-do list at the end of the working day, instead of waiting until the start of the next working day.