Paba Logo

How to conquer developer cognitive load

cover image
Hasini Tharupaba
Hasini TharupabaAuthor

This post is about how we can get inspiration from cognitive psychology to have a better developer experience.

Have you ever felt like your brain is full of tasks? If so, this happens when your mind does multiple activities at the same time. In cognitive psychology, this is a concept called Cognitive Load which means how much information the working memory can hold onto at any one time. Working memory is, loosely speaking, the part of the cognitive system that processes information related to what the individual is currently doing (in contrast to long-term memory, which retains structured knowledge). We know that working memory is quite limited in its capacity (try remembering a phone number after hearing it once) and is vulnerable to overload.

Programming-related tasks are reliant on the working memory. We are frequently working with mental models as we load programs into our brains. For instance, when we look at a new, unfamiliar piece of code, we take time to take it to mind and create a mental model. Nevertheless, even if we've been maintaining a particular software for years, we take some time to process the model before working on it. Any non-trivial software system is so complex that no individual developer can understand or remember how the whole thing works all of the time. Thus, we have to re-familiarise ourselves with the inner work of a particular part of the codebase before we start making changes or fixing bugs. Maintaining software is essentially a continual learning process that we can apply to the concept of cognitive load.

There are three types of cognitive load.

  1. Intrinsic cognitive load

    This is the complexity of learning the task itself. For instance, when learning how to make a cake, it would be the effort required to weigh and combine all of the ingredients correctly, stir the batter just the right amount, preheat the oven, time the baking correctly, and so on.

  2. Germane cognitive load

    This means linking new information with current information. Part of the recipe might explain how to make the icing in great detail. Over time, however, an experienced baker will learn how to make the icing, and so that part of the overall cake-making task will be reduced to simply "make the icing".

  3. Extrinsic cognitive load

    This is the additional and unnecessary effort taken in the learning process. In the cake example, imagine if all of the units are given in pounds and ounces. But you are familiar with working in grams and kilograms. The extrinsic load would be the time spend converting between imperial and metric at every step of the way.

If you are a developer, you may already have insights into how these types of cognitive load can relate to your daily tasks. We all would agree that the primary job of developers is to write efficient code. But usually, they have other responsibilities and distractions such as managing emails, notifications, messy processes, and complex organizational structures. This extra workload can increase developer cognitive load. Software development is knowledge work so some load is expected but some can be avoided.

How can we mitigate developer cognitive load?

First of all, we identified two main ways that increase developer cognitive load. One is the coding itself while the second way is having other distractions such as calls and emails. Here are some of the activities that can assist to mitigate the cognitive load.

  1. Use developer tools that reduce the workload in smart ways. Great documentation, frameworks, and other general tools can minimize the time you spend on learning and other certain tasks.

  2. Utilize and adopt great DX (developer experience) pillars in your products. Great function, stability, clarity, and ease of use can minimize cognitive load. When the products that you use have these qualities, your extrinsic load minimizes or completely goes away. When the products have positive DX, the time you spend learning new updates and fixing functionality issues reduces.

  3. Keep better code comments. When there are comments for the functions that you write, you spend less time to re-familiarize yourself with the codebase. Also if other developers uses the code, they will spend less time understanding and creating a mental model of the codebase.

  4. Focus on useful messages prioritizing development activities during work. It will reduce unnecessary emails, notifications, tasks, and processes.

  5. Keep better abstraction. Sometimes the abstraction we have built can result in a set of tools that are harder to use, hard to understand and reason about, and most importantly harder to change than the explicit. We need abstraction that does not go to an extreme level on either side.