Deep Work for Programmers: Protecting Focus
Programming needs long uninterrupted blocks. Learn how to protect them, how to batch the shallow work, and how to measure the result.
By Velloreth
Why focus matters
Programming is a stateful task. The programmer holds a model of the code, the goal and the current hypothesis.
An interruption discards part of the model.
The cost is not the interruption. It is the minutes of rebuilding afterwards.
A study of knowledge workers found that after an interruption it takes a significant time to return to the original task, and that the workers compensate by working faster, which increases the error rate.
The consequence: a day of fragmented work produces less than a morning of focused work.
The block
A block of 90 minutes is long enough to reach a productive state and short enough to sustain.
A block of 90 minutes is worth more than three blocks of 30, because the startup cost is paid once.
Two or three blocks a day is a realistic target.
The block needs:
- A defined start and end
- A single task
- No notifications
- A way to capture a stray thought without acting on it
The startup cost
The first ten minutes of a block are spent rebuilding the context.
The fix: end the previous block with a note.
Next: the cache invalidation is not firing on profile update.
Hypothesis: the key is built from the old id.
Check: the key builder in cache.ts line 42.
The note removes the startup cost, because the context is written down rather than remembered.
A written plan for the block is the same idea applied at the start.
Batching the shallow work
Shallow work is a task that can be done while distracted. A message, a review, a ticket update.
The problem: it arrives continuously, so it interrupts continuously.
The fix: a defined window.
The pattern:
| Time | Work |
|---|---|
| Morning | a deep block |
| Midday | a deep block |
| Afternoon | a shallow batch |
| End of day | a plan for tomorrow |
Batching removes the repeated context switch, because the shallow work is done once.
The environment
Notifications off. A notification is an interruption even when it is ignored.
A separate device or profile for the shallow work, so the deep work environment has no channel.
A visible signal. A status, a closed door, a calendar block. The signal sets the expectation.
A capture list. A stray thought is written down and handled in the batch, not acted on.
A single task. A block with two tasks is two blocks with a startup cost each.
The team norms
A response time, not an instant reply. A norm of a few hours for a message, with a separate channel for a genuine emergency.
Published focus blocks. The expectation is explicit rather than a surprise.
A review window. A pull request is reviewed in the batch, not the moment it is opened.
A meeting-free day or morning. A shared block where nobody schedules.
An on-call rotation. The emergency channel is covered by a person, so the rest can focus.
The measurement
Measure the output, not the hours.
| Output | Signal |
|---|---|
| A merged pull request | a shipped change |
| A resolved bug | a problem closed |
| A decided design | a decision made |
| A review completed | a teammate unblocked |
Counting the hours is a proxy that is easy to game. The output is the thing that matters.
A weekly review of the output is more useful than a daily count of the hours.
The traps
A block that is not protected. A meeting is scheduled over it.
A block with no task. The time is spent deciding what to do.
A block that is too long. Two hours without a break is less productive than 90 minutes with one.
A shallow task in a deep block. The block is wasted.
A notification that is “just a quick look”. It is an interruption.
A culture that rewards the instant reply. The norm defeats the block.
A block with no note at the end. The next block pays the startup cost.
Measuring the hours. A proxy that rewards presence.
A weekly rhythm
A deep work practice is easier to sustain as a weekly rhythm than as a daily rule. The week has two or three protected mornings, a shallow batch in the afternoon, and a review at the end. The review asks three questions: what shipped, what blocked the blocks, and what to change next week. The second element is a buffer: a day with no deep block, so a week that goes wrong does not collapse the whole practice. The third is a visible record, because a list of what shipped is the evidence that the practice works, and the evidence is what keeps it going when a busy week makes it feel optional. A practice that survives a bad week is a practice that lasts.
Common mistakes
No protected block. The day fills with shallow work.
No task for the block. The time is spent deciding.
Notifications on. A continuous interruption.
No capture list. A stray thought derails the block.
No note at the end. The startup cost is paid again.
A team norm of instant replies. The block is impossible.
Measuring the hours. The wrong signal.
A block that is too long. Diminishing returns.
No weekly review. The pattern is invisible.
A quotable summary
Deep work is focused, uninterrupted work on a cognitively demanding task, and a context switch costs far more than the interruption itself because the mental model must be rebuilt. A block of 90 minutes is worth more than three blocks of 30, the shallow work is batched into a defined window, and a note at the end of a block removes the startup cost of the next one. Measure the output, not the hours.
Related reading
For the related topics, see avoiding-developer-burnout and learn-programming-without-tutorial-hell. For the broader context, remote-team-building-small-companies and asking-good-technical-questions.