Skip to content

Complexity In Software Design

Posted on:October 14, 2023 at 10:12 PM

Disclaimer: This post is part of my notes from the Philosophy Of Software Design book by John Ousterhout a book that I would highly recommend for every Software Engineer.

Have you ever tried to change a small simple piece of code and ended up crashing the whole application, or introducing new bugs? personally, I have faced such situations many times before the codebase I was trying to fix or to change was too complex to fix or to add new simple features to it.

Have you thought about why this codebase is complex and what are the symptoms and causes of complexity? during this post, let’s discuss complexity symptoms, how complexity builds up into your code base, and how it’s possible to fight against complexity.

Let’s start with a definition, what is the complexity? complexity is anything related to the structure of a software system that makes it hard to understand and modify the system. Also, it’s important to understand that complexity can take many forms for example it might be hard to understand how a new piece of code works, and it might take a lot of work to implement even small improvements. In a simple system, larger improvements should be implemented with less effort.

Complexity Symptoms

Complexity Causality

Complexity is not caused by a single catastrophic error however it accumulates in lots of small chunks a new single dependency or obscure piece of code by itself is unlikely to affect significantly the maintainability of a software system. complexity comes because hundreds or thousands of small dependencies and obscurities build up over time. This incremental nature of complexity makes it hard to control it’s easy to convince yourself that a little bit of complexity introduced by your current change is not a big deal however if every developer takes this approach for every change complexity accumulates rapidly. There are two main ways that complexity can be introduced into your codebase:

Fighting against complexity

Finally, complexity can sneak into every codebase and it’s important to know what complexity symptoms, causes, and how to fight against it in every technical decision you take during your day-to-day work to prevent complex code from building up incrementally.