Causes of Complexity
2025-02-16 21:03
Status: #adult
Tags: #philosophy #software #design #books
Causes of Complexity
The causes could be summarized to two things:
- Dependencies
- Obscurity
A dependency exists when a given piece of code cannot be understood and modified in isolation; the code relates in some way to other code, and the other code must be considered and/or modified if the given code is changed.
Ex.
In network protocols, there is a separate software piece for sender and receiver for the protocol, but they must each conform to the shared protocol; changing the code for the sender must always require corresponding changes to the implementation of the receiver, and vice versa.
Same thing could be seen in normal changes to functional dependencies. If one would add a new parameter to a function, then all previous invocations of that function might need to change (not always true since we can add a default value..)
Note that dependencies are a fundamental part of software and can't be completely eliminated. In fact, we intentionally introduce dependencies as part of the software design process. The goal of software design is to reduce the number of dependencies and make the dependencies that remain as simple and obvious as possible.
The second cause of complexity is obscurity. Obscurity occurs when important information is not obvious. A simple example is a variable name that is so generic that it doesn't carry much useful information (e.g., time). Or, the documentation for a variable which doesn't specify the units so the only way to know is to infer.. Obscurity is often associated with dependencies, where it is not obvious that a dependency exists. For example, if a new error status is added to a system, it may be necessary to add an entry to a table holding string messages for each system, it may be necessary to add an entry to a table holding string messages for each status, but the existence of the message table might not be obvious to a programmer looking at the status declaration Inconsistency is also a major contributor to obscurity: if the same variable name is used for two different purposes, it won't be obvious to developers which of these purposes a particular variable serves.
Note that complexity isn't caused by a single catastrophic error; it accumulates in lots of small chunks. A single bad design decision or obscure name, by itself, is unlikely to affect significantly the maintainability of a software system. Things do build up though and can eventually lead to a legacy system that is hard to work with and maintain. However, since a bit of complexity doesn't break the whole thing, it becomes easy to convince oneself that a little bit of complexity introduced by a small change is no big deal. However, if every developer takes responsibility and thinks from a complexity reducing framework then the system will be in a much better state as a whole!
References
It's all about complexity
Symptoms of Complexity