The four rules of simple design


Simplicity in software design results in cleaner code, easier maintenance, and more intuitive applications.

The four rules of simple design, proposed by Kent Beck, creator of the Extreme Programming (XP) methodology, are designed to help developers focus on what’s most important and avoid unnecessary complexity in their code. That is, designing software with a focus on the Keep It Simple, Stupid! (KISS) principle. These four rules, in order of priority, are as follows:

1. Passes all tests

Simplicity means functionality. If the code doesn’t work as expected, other aspects like elegance or minimalism don’t matter. Therefore, a design is only simple if it passes all tests.

This rule also emphasizes the importance of the Test-Driven Development (TDD) methodology, where writing tests before writing code ensures that only what is necessary for the software to work is written.

Its benefits are:

2. Reveals intention

A simple design is one in which the code communicates the developer’s intent. When reading the code, it should be immediately clear what it does and why. Code that expresses intent avoids tricks, complex constructs, or obscure patterns in favor of straightforward, understandable logic. Any developer who hasn’t written the code should be able to read and understand it as if it were a story in a book. For this reason, the use of some features, such as reflection, should only be employed when it is by far the best option.

This rule emphasizes that code is written to be read by humans, not just executed by machines. If a piece of code is difficult to understand or requires extensive documentation to explain its purpose, then it is not simple. Clear and concise code allows others to understand the logic with minimal effort, reducing cognitive load.

When it comes to comments, their goal should not be to explain what the code does; it should be self-explanatory. Comments should be reserved for specific cases where you want to clarify the motivations behind a business decision, not the behavior or state of the code.

Its benefits are:

3. No duplicated logic

This is none other than the well-known software design principle, Don’t Repeat Yourself (DRY). Duplication in code creates redundancy, higher maintenance costs, and a greater likelihood of errors. Simple design seeks to eliminate unnecessary duplication by abstracting common functionality into shared components or functions. This rule promotes modularity and reuse, two crucial aspects of clean, maintainable software.

When a feature or behavior is duplicated across multiple parts of the system, it creates the potential for inconsistencies. Fixing a bug or changing behavior in one place may not fix it everywhere, leading to confusion and errors. Conversely, when the system is designed to minimize duplication, changes are easier to manage, and the software remains flexible to future changes.

This rule is to behavior what Single Source of Truth (SSOT) or Single Point of Truth (SPOT) is to state.

Its benefits are:

4. Fewest possible elements

The tendency to add unnecessary features or functionality that do not contribute to the software’s primary goals should be avoided. Each function or component of a system should have a clear purpose: to satisfy a need and provide value. Otherwise, it should be removed.

This rule encourages developers to focus on what matters. It challenges them to prioritize the most essential parts of the system and avoid being distracted by non-essential features or excessive architecture. The goal is to implement only what is necessary to solve the problem at hand and nothing more.

When this rule is applied to feature development, it translates into the You Aren’t Gonna Need It (YAGNI) principle.

Its benefits are:

Conclusion

These four rules, like the goal they pursue, are simple. They are easy to apply, remember, and internalize. Following them ensures that the resulting code will meet the design simplicity necessary to be maintainable and scalable over time. They are an indispensable resource that every developer should have in their toolbox.

More about:

2025-08-11
Written by Samuel de Vega.
Tags