Accidental or necessary complexity

Whether necessary or accidental, there is no way to avoid complexity when dealing with software systems. These separation is made by Fred Brooks on The Mythical Man-Month.

Necessary complexity is the one inherent to the problem at hand, to the specific domain.

Accidental complexity is the one produced by a large code base that leads to a complex system (not understood by a single person), which will have bugs that, if not well solved (address root cause, rethink design and write regression tests), will lead to a larger code base (because good designs/solutions tend to be smaller).

To reduce accidental complexity you should try to be clear when designing (abstractions and modular design) and programming (testing and refactoring). Always ask yourself if the code is clear enough to be understood.

Recommendation: Pay attention to one aspect of the code and try to isolate it and reason about it. Try to separate the necessary from the accidental. Could you put that aspect in an independent module?