3 The complex art of simplicity
This chapter covers
- Understanding code complexity
- Measuring cognitive complexity
- Using six levers to strive for simplicity
Now, let’s turn to another essential dimension in the rosette of beautiful code: simplicity. Simplicity is widely recognized among developers by the famous acronym KISS, which stands for “Keep It Simple, Stupid.” If you prefer a softer version, it can also mean “Keep It Short and Simple,” or, for a more playful take, “Keep It Sweet and Simple.” In any case, the idea remains the same: whether it’s short, sweet, or even stupid, it must be simple.
This principle dates back to the 1960s, when the U.S. Navy first applied it to the design of military aircraft. It states that any system should be kept so simple, almost to the point of seeming stupid, that even a non-expert can understand it.
Such simplicity greatly enhances long-term maintainability. Yet, that brief piece of advice doesn’t come with an instruction manual, and achieving simplicity can be extremely complex. So, the best way to explain simplicity is to start by understanding complexity.
We’ll first explore what complexity is, how it creeps into code, and how to measure it. Then, we’ll introduce six concrete levers you can use to strive for simplicity. Each lever addresses a specific dimension of complexity and offers hands-on strategies to restore clarity to your codebase.