For the purposes of this book, I define “complexity” in a practical way. Complexity is anything related to the structure of a software system that makes it hard to understand and modify the system. Complexity can take many forms. For example, it might be hard to understand how a piece of code works; it might take a lot of effort to implement a small improvement, or it might not be clear which parts of the system must be modified to make the improvement; it might be difficult to fix one bug without introducing another. If a software system is hard to understand and modify, then it is complicated; if it is easy to understand and modify, then it is simple.

For the purposes of this book, I define “complexity” in a particular way, as anything about the structure of a system that makes it difficult to understand and adjust. Complexity can take many forms. For example, it may be difficult to understand how a piece of code works; Maybe it takes a lot of work to make a little improvement; It may not be clear which parts of the system to tweak will improve. Maybe it’s hard to fix one BUG without causing other bugs. A software system is complex if it is difficult to understand and modify; The opposite is simple.

You can also think of complexity in terms of cost and benefit. In a complex system, it takes a lot of work to implement even small improvements. In a simple system, larger improvements can be implemented with less effort.

You can also view complexity as costs and benefits. In complex systems, it takes a lot of work to make even small improvements. In simple systems, much more improvement can be achieved with much less effort.

Complexity is what a developer experiences at a particular point in time when trying to achieve a particular goal. It Does not necessarily relate to the overall size or functionality of the system describe large systems with sophisticated features, but if such a system is easy to work on, then, for the purposes of this book, it is not complex. Of course, almost all large and sophisticated software systems are in fact hard to work on, so they also meet my definition of complexity, but this need not necessarily be the case. It is also possible for a small and unsophisticated system to be quite complex.

Complexity is what a developer has to go through at a particular point in time to achieve a particular goal. It is not necessarily related to the overall size or functionality of the system. People often use the word “complex” to describe a system with complex functions, but if such a system is easy to develop, then for the purposes of this book, it is not complex. Of course, almost all large and complex software systems are actually very difficult to develop, so they will show up in my definition of complexity, but that doesn’t have to be the case. A small and uncomplex system can be very complex.

Complexity is determined by the activities that are most common. If a system has a few parts that are very complicated, but those parts almost never need to be touched, then they don’t have much impact on the overall complexity of the system. To characterize this in a crude mathematical way:

Complexity depends on the most common activities. If only a small part of a system is very complex, but these parts are almost never touched, then they have little impact on the overall complexity of the system. Let’s quantify it with this crude mathematical formula:

The overall complexity of a system (C) is determined by the complexity of each part p (cp) weighted by the fraction of time developers spend working on that part (tp). Isolating complexity in a place where it will never be seen is almost as good as eliminating the complexity entirely.

The overall complexity (C) of the system is determined by the complexity (CP) of each part weighted by the developer’s time spent on development (TP). Isolating complexity to a place where it can never be seen again is almost as effective as eliminating complexity as a whole.

Complexity is more apparent to readers than writers. If you write a piece of code and it seems simple to you, but other people think it is complex, then it is complex. When you find yourself in situations like this, It’s worth exploring the other developers to find out why the code seems complex to them; there are probably some interesting lessons to learn from the disconnect between your opinion and theirs. Your job as a developer is not just to create code that you can work with easily, but to create code that others can also work with easily.

The reader will see the complexity more easily than the writer. If you write a piece of code that is simple to you but complicated to others, then it is complex. If you find yourself in this situation, it’s helpful to go to other developers and find out why they think your code is complex. There are likely to be some interesting lessons to learn in your disagreement with them. As a developer, your job is not only to write code that is easy for you to use, but also to create code that is easy for others to work with.