Mahamudul Hasan Rubel
HomeBlogCoursesAboutProjectsSkillsExperiencePhotosContact
Mahamudul Hasan Rubel

Senior Software Engineer crafting high-performance web applications and SaaS platforms.

Navigation

  • Home
  • Blog
  • Courses
  • About
  • Projects
  • Skills
  • Experience
  • Photos
  • Contact

Get in Touch

Available for senior/lead roles and consulting.

bd.mhrubel@gmail.comHire Me

© 2026 Mahamudul Hasan Rubel. All rights reserved.

Built with using Next.js 16 & Tailwind v4

Back to Blog
ProductivityJune 25, 20264 min read

Developer productivity: How to minimize context switch tax

Developer productivity plummets when cognitive load is high. Learn how to structure your codebase to reduce context switching and reclaim your deep work.

developer productivitysoftware engineeringdeep workcodingarchitectureProductivityFocusWork

When I’m in the middle of a complex refactor, the last thing I need is a 10-minute detour into a tangled dependency graph just to change a single boolean flag. We’ve all been there: you open a file, lose the thread of logic, and suddenly you’re staring at a Slack notification wondering what you were doing.

Reducing cognitive load through codebase architecture

The "context switch tax" is real. Every time you jump between unrelated modules or struggle to parse a sprawling, monolithic service, you pay a toll in mental energy. To maintain developer productivity, we have to treat our codebase as a cognitive interface, not just a collection of instructions for a machine.

I used to think that "clean code" was mostly about aesthetics or following a specific linting rule. I was wrong. A few years ago, while working on a legacy Node.js service, I spent about two days trying to trace an event-driven flow that spanned seven different directories. The architecture wasn't just "messy"—it was a cognitive trap. By the time I found the root cause, I’d completely lost the mental model of the feature I was building.

If you’re looking to protect your focus, you might find my guide on how I actually get deep work done as an engineer useful for setting up the environment, but the code itself needs to be designed for clarity.

Why modularity matters for focus

The most effective way to lower the tax is to enforce boundaries. When your modules are strictly decoupled, you only need to keep a small slice of the system in your head at once. This is the essence of building mental models for software engineering to build better systems.

Here is what I’ve started doing to keep my brain from melting:

  1. Colocate by feature, not by type: Stop putting all your controllers in one folder and all your services in another. Keep the user.controller.ts, user.service.ts, and user.model.ts together.
  2. Standardize the entry points: If I have to guess how a module is initialized, I’ve already failed. Use an index.ts file that explicitly exports the public API.
  3. Minimize deep nesting: If your directory tree looks like a labyrinth, your mental map will be one, too. Keep your project structure flat enough that you can visualize it in your IDE’s sidebar without scrolling.

The cost of "clever" code

We often fall into the trap of writing "clever" code—abstractions that look elegant but hide the actual control flow. I once spent an entire afternoon debugging a hidden dependency injection pattern that was essentially a magic black box. It saved me five lines of code but cost me three hours of productive time.

When you’re designing for developer productivity, prioritize readability over brevity. If a junior dev (or "future you") can’t look at a function and immediately understand the inputs and outputs, the architecture is failing.

Tools for managing attention

I’ve found that using the right tools can act as a buffer against the context switch tax. For example, I rely heavily on git worktree now. It allows me to keep my main branch clean while I explore a new feature in a separate directory. It sounds like a small change, but it means I don't have to stash or rebase just to check a quick bug fix on production.

Similarly, I use a strict tsconfig setup to enforce path aliases. Instead of: import { Logger } from '../../../../utils/logger';

I use: import { Logger } from '@app/utils/logger';

It’s a minor tweak, but it reduces the visual noise in every single file. When you’re trying to stay in software engineering flow, every distraction counts. You can learn more about managing these boundaries in my piece on remote work productivity: How to Master Deep Work as a Freelancer.

Closing thoughts on codebase architecture

I’m still not perfect at this. Last week, I caught myself over-engineering a small utility library, adding layers of abstraction that I didn't need. It’s tempting to build "future-proof" systems, but usually, that just leads to more cognitive load for yourself later.

Next time, I’m going to try to embrace "good enough" architecture from the start. I’d rather have a simple, slightly repetitive codebase that I can navigate in seconds than a perfectly DRY, highly abstract system that requires a map and compass to traverse. What about you? Do you find that your codebase helps you stay in the zone, or does it constantly pull you out?

Frequently Asked Questions

How does codebase architecture affect deep work? A well-structured codebase minimizes the amount of information you need to keep in your working memory. When the code is intuitive, you spend less energy navigating and more energy solving the actual problem.

Is it always better to colocate files? Generally, yes. Colocating files by feature makes it easier to understand the lifecycle of a specific piece of functionality, which is the primary driver of context switching.

What is the "context switch tax" in code? It’s the mental overhead incurred when you move between different parts of a codebase that aren't clearly related or documented. The more "jumping around" you have to do to understand a feature, the higher the tax.

Back to Blog

Similar Posts

ProductivityJune 23, 20264 min read

Protecting my attention with these simple engineering tools

Protecting my attention is a constant battle for engineers. Learn how I use specific CLI tools and environment automation to minimize distractions and stay deep.

Read more
Close-up of a hand writing in a notebook with checkboxes, highlighting productivity and organization.
ProductivityJune 20, 2026
4 min read

How I actually get deep work done as an engineer

Deep work for engineers isn't about hacks. I share the real-world rituals, environment controls, and tool-based boundaries I use to ship code consistently.

Read more
LearningJune 26, 20264 min read

Mental Models: Control Theory for Better Software Engineering

Master mental models from control theory to improve your software engineering feedback loops. Learn to boost engineering productivity by stabilizing your code.

Read more