| 1 | --- |
| 2 | title: "Complexity Budget" |
| 3 | description: "In this essay, Carson Gross explores the concept of a complexity budget in software development. He discusses how managing complexity across applications is a critical responsibility for architects and developers, while examining strategies for effective complexity management and the challenges that arise when attempting to reduce it." |
| 4 | created: 2020-10-29 |
| 5 | modified: 2024-01-21 |
| 6 | authors: ["Carson Gross"] |
| 7 | tags: ["simplicity"] |
| 8 | --- |
| 9 | |
| 10 | Every software project involves managing a complexity budget. |
| 11 | |
| 12 | A complexity budget can be defined as: |
| 13 | |
| 14 | > An explicit or implicit allocation of complexity across the entire application |
| 15 | |
| 16 | "Complexity" here is defined subjectively (rather than [formally](https://en.wikipedia.org/wiki/Programming_complexity)) |
| 17 | and in [Stewartian Terms](https://en.wikipedia.org/wiki/I_know_it_when_I_see_it): "I know it when I see it." |
| 18 | |
| 19 | Or, more specifically to software development: "I know it when I *feel* it." |
| 20 | |
| 21 | One of the primary jobs of an application architect is to manage a projects complexity budget: |
| 22 | |
| 23 | * Decide if a given feature is "worth it" |
| 24 | * Decide if a given implementation is "worth it" |
| 25 | * Add appropriate system boundaries to limit complexity between components |
| 26 | * And so on |
| 27 | |
| 28 | An infuriating aspect of complexity is that that attempts to address it can, in fact, add more complexity. |
| 29 | |
| 30 | A good example of this from experience was when a company I worked at added [OSGi](https://en.wikipedia.org/wiki/OSGi) |
| 31 | to the system to manage the |
| 32 | increasing complexity of the project. It seemed like a reasonable approach, |
| 33 | it offered a sophisticated [module](https://www.osgi.org/resources/what-is-osgi/) system, |
| 34 | it was recommended by a newly hired architect, and it even says on the "What is OSGI page": |
| 35 | |
| 36 | > OSGi significantly reduces complexity in almost all aspects of development: code is easier to write and test, reuse is |
| 37 | > increased, build systems become significantly simpler, deployment is more manageable, bugs are detected early, and |
| 38 | > the runtime provides an enormous insight into what is running. |
| 39 | |
| 40 | What's not to like? |
| 41 | |
| 42 | Unfortunately, adding OSGi to that project effectively ground the entire project to a halt: it took a few of our best |
| 43 | engineers out of normal application development for over a year, and when they were done the codebase was even more |
| 44 | difficult to work with than when they started. Feature velocity, already teetering, collapsed. |
| 45 | |
| 46 | This is not to say OSGi is universally bad. But, in this case, rather than boosting our development teams productivity, |
| 47 | it effectively ended it. |
| 48 | |
| 49 | A good software architect is someone who manages the software budget of their project effectively, either explicitly or |
| 50 | implicitly. |
| 51 | |
| 52 | ## Complexity Growth |
| 53 | |
| 54 | My sense, admittedly without hard evidence, is that Stewartian Application Complexity grows roughly geometrically with |
| 55 | the size of an application. Proper [factoring](https://en.wikipedia.org/wiki/Decomposition_(computer_science)) by |
| 56 | experienced developers can hold this curve down for quite some time. |
| 57 | |
| 58 | However, this doesn't change the fact that, somewhere out there, there is a Complexity Wall lurking. |
| 59 | |
| 60 | And, if you aren't careful, you will run headlong into it and grind your development velocity to a halt. |
| 61 | |
| 62 | I have had multiple experiences with this: one day, inexplicably, development on a system that I was working on went |
| 63 | from feeling "large, but manageable" to "this is impossible to deal with". |
| 64 | |
| 65 | ## Spending Your Complexity Budget Wisely |
| 66 | |
| 67 | Here are some tools for managing your complexity budget: |
| 68 | |
| 69 | 1. Foremost: understanding that there *is* a complexity budget that needs to be managed |
| 70 | 1. Focus your "complexity spend" on the areas where your application is adding value and/or differentiates itself |
| 71 | 1. Saying "No" - probably the easiest, best and, also, hardest tool to use in your battle with complexity |
| 72 | 1. Embracing [KISS](https://en.wikipedia.org/wiki/KISS_principle), even if it means admitting you are stupid (Note that |
| 73 | it's often very good for an organization if the senior developers can admit they are fallible) |
| 74 | 1. Proper factoring of components - this is an art: Too many components and your complexity explodes. Too few... same. |
| 75 | 1. Choosing the proper balance of expressiveness and restrictions for a component |
| 76 | |
| 77 | Unfortunately, experience shows that managing Stewartian Complexity is a subjective endeavor and that many talented and |
| 78 | experience developers will disagree on the proper course of action at a given decision point. |
| 79 | |
| 80 | Nonetheless, by making the concept of a complexity budget explicit in your software project, these conversations can be |
| 81 | more productive and ultimately lead to better software outcomes. |
| 82 | |
| 83 | ## A Final Note |
| 84 | |
| 85 | Almost all mature applications are complex. |
| 86 | |
| 87 | Finding a new codebase "complex" is *not* an excuse for tearing everything apart or aggressive refactoring. We must |
| 88 | always bear in mind [Chesterton's Fence](https://fs.blog/2020/03/chestertons-fence/). |
| 89 | |
| 90 | If an application is functioning well (or even reasonably) then we should assume that the complexity budget was well |
| 91 | (or at least reasonably) managed. |
| 92 | |
| 93 | And we must always remember that, with unfortunate frequency, big attempts at addressing complexity in existing, large |
| 94 | applications often fail or, sadly, make things worse. |