Code complexity

One of the leading causes of bugs in software is the complexity of the system. Simple, well-written code is less buggy and more easily maintainable. Complex code is hard to write bug-free, and subsequently hard to maintain.

One measurement we can use to assess our code's maintainability is called cyclomatic complexity, best described as the number of paths that go through one piece of code. The more paths going through part of our system, the more likely it is to be complex and have to cater to different parameters or conditions. This makes the code harder to read and comprehend, and therefore more likely to contain or introduce bugs.

Unreadable code is the biggest single source of bugs in software, mainly because it's hard ...

Get The Agile Developer's Handbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.