Complex code is harder to read and understand than simple code. As a developer, you’ve likely experienced the mental strain of deciphering a 200-line method compared to a 20-line method. You feel tired even before you begin to read it. Highly complex code is also more prone to bugs. It’s easier to make mistakes in code that’s difficult to grasp. It’s also hard to write tests for complex code, as it has too many possibilities and corner cases to explore, and it’s too easy to forget one of them.
Making code simple and small is the first thing you should always consider. Even with a well-designed software system, it’s easy to lose sight of code complexity. Lines of code tend to become overgrown if we don’t actively work to prevent it, leading to oversized classes. Long classes and methods happen more often and more naturally than we like to admit. It’s too easy to open an existing class in the system and add more code instead of reflecting on the impact of these new lines and redesigning the code.