π§ ππ Cognitive load is what matters

π€ AI Summary
- π§ Cognitive load is how much a developer needs to think in order to complete a task.
- π§ The average person can hold roughly four chunks of information in working memory; cognitive overload occurs once this threshold is passed.
- π Focus must be placed on reducing extraneous cognitive load, which is created by the way information is presented, rather than the intrinsic load, which is the inherent difficulty of the task.
- π‘ Use intermediate variables with meaningful names to break down complex conditionals.
- β©οΈ Employ early returns to focus on the happy path, thus freeing working memory from precondition checks.
- π§± Prefer composition over inheritance to avoid an inheritance nightmare where functionality is scattered across multiple classes.
- π Deep modules are superior to shallow modules because they provide powerful functionality yet have a simple interface, maximizing information hiding.
- ποΈ Information hiding is paramount, and shallow modules do not effectively hide complexity.
- π₯ The Single Responsibility Principle means a module should be responsible to one, and only one, user or stakeholder, not just performing βone thing.β
- π Too many shallow microservices lead to a distributed monolith, causing debugging issues and unacceptably high time to market and cognitive load.
- βοΈ Limit the number of choices and reduce cognitive load by using language features that are orthogonal to each other.
- π The mindset βWow, this architecture sure feels good!β is misleading; a far better approach is to observe the long-term consequences, like ease of debugging and new developer onboarding time.
- π΄ The best code is often boring and straightforward, not the most elegant or sophisticated.
π€ Evaluation
- π‘οΈ While this philosophy champions simplicity, Clean Code and Domain-Driven Design (DDD) advocate for structured complexity and rigorous separation of concerns.
- βοΈ Clean Code often encourages many small functions and classes, which this article labels as shallow modules that ultimately increase cognitive load by forcing developers to mentally untangle numerous interactions.
- π§© DDD aims to manage intrinsic complexity by aligning code with the business domainβs ubiquitous language, which could arguably reduce future cognitive load, even if the initial learning curve of the mental models is steep.
- π Identify topics to explore for a better understanding.
- π¬ Further exploration is needed into the scientific definition of cognitive load (intrinsic, extraneous, and germane) to better match the informal application in software engineering contexts.
- π The concepts of βDeepβ vs. βShallowβ modules require practical, domain-agnostic metrics beyond mere line count to guide architects on optimal component and service boundary delineation.
- π§βπ» Research into the onboarding timelines of new engineers in well-crafted monoliths versus distributed systems would provide empirical data to conclusively support the argument against overly granular microservices.
π Book Recommendations
- π‘ Similar
- A Philosophy of Software Design: π Reinforces the concepts of deep modules and complexity reduction through principles like information hiding and simple interfaces.
- π§βπ€βπ§βοΈβ‘οΈ Team Topologies: Organizing Business and Technology Teams for Fast Flow: πΊοΈ Provides a better framework for splitting cognitive load across teams by defining clear team interaction patterns and service boundaries, contrasting with the ambiguity of some DDD principles.
- π₯ Contrasting
- π§ΌπΎ Clean Code: A Handbook of Agile Software Craftsmanship: π Advocates for many of the practices the article labels as harmful, such as extremely short functions and classes, which the author argues lead to mentally taxing shallow modules.
- π§©π§±βοΈβ€οΈ Domain-Driven Design: Tackling Complexity in the Heart of Software: π° Focuses on managing the intrinsic complexity of a domain through modeling, potentially increasing extraneous cognitive load initially, but promising long-term clarity within bounded contexts.
- π Creatively Related
- π€ππ’ Thinking, Fast and Slow: π§ Explores the two systems of thought in the brain, providing a psychological basis for why code should be designed to minimize effortful, high cognitive load (System 2) thinking.
- πΊπͺπ‘π€ The Design of Everyday Things: π οΈ Discusses how good design minimizes the cognitive effort required to use physical objects, a principle directly applicable to designing software interfaces and codebases for human consumption.
π¦ Bluesky
π§ ππ Cognitive load is what matters
AI Q: π§ Is boring and straightforward code always better than elegant complexity?
π» Software Engineering | π§ Working Memory | ποΈ Architecture Design | π οΈ Programming Best Practices
β Bryan Grounds (@bagrounds.bsky.social) 2026-07-18T21:32:46.000Z
https://bagrounds.org/articles/cognitive-load-is-what-matters