chapter three

3 The complex art of simplicity

 

This chapter covers

  • The basics of code complexity
  • Measuring cognitive complexity
  • Using six levers to strive for simplicity

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 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 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.

The best way to understand simplicity is to begin with complexity. First, we’ll explore what complexity is, how it creeps into code, and how to measure it. Then, we’ll examine six concrete levers that can help you achieve simplicity. Each lever addresses a specific dimension of complexity and offers hands-on strategies for restoring clarity to your codebase.

3.1 Complexity

3.1.1 Code complexity

3.1.2 Measuring cognitive complexity

3.2 Simplicity

3.2.1 The Prevent lever

3.2.2 The Organize lever

3.2.3 The Reduce lever

3.2.4 The Hide lever

3.2.5 The Investigate lever

3.2.6 The Endure lever

Summary