Tame Complexity

Understand the two sources of complexity in software development, necessary and accidental complexity.

Sources of complexity

In industry, it won’t be long before we run into a mind-boggling mess of code: The Behemoth, The Spaghetti Factory, The Legacy System from Hell, all names of the same dreaded problem.

Complexity in software systems is unavoidable. Some problems are just hard, and their solutions are complex. However, much of the complexity we find in software is a mess of our own making. In the book “The Mythical Man-Month”, Fred Brooks separates the two sources of complexity into necessary and accidental complexity.

Here’s a way to consider the difference between necessary and accidental complexity: what complexity is inherent in the problem domain? Let’s say we’re faced with a program that has date/time-handling code scattered all over the place. There’s some necessary complexity when handling time. Months have different numbers of days, and we have to consider leap years and so forth. But most programs have loads of accidental complexity relating to time: times stored in different formats, novel (and buggy) methods to add and subtract times, inconsistent formats for printing times, and much more.

Get hands-on with 1200+ tech skills courses.