Bad Design: Big Ball of Mud
Brian Foote and Joseph Yoder wrote an amazing metaphoric article on the most common "architecture" which they call the Big Ball of Mud.
We have all had the experience of working on bad code which is difficult to read or change. The original developers may not have been bad developers but over time the code went bad. So why does code go bad? The answer is code doesn't go bad, developers make it bad. Everytime developers touch the code and make changes they either improve the code or make it worse. Why do developers make it worse:
- The developers are rushed
- The original design was poor - high viscosity and other symptoms of Bad Code.
- The developer working on it has a poor understanding of the system or design
Of course we all like to blame it on the original design, yet make no effort to improve the state of the system. Everyone agrees that we should avoid bad code yet it pops up all the time anyway.
Shanty town metaphor
The big ball of mud article uses the metaphor of a shanty town, where there is a large demand for immediate housing but there is not enough money or skill, so cheap low quality dwellings are erected.
The metaphor of a shanty town, illustrates a result of:
- Simple/poor tools
- Cheap unskilled labour
- No specialists - the builder is a jack of all trades
- No planning or regulaion of growth.
- High immediate need - rushed job
Simply put, with little time, skill, capital; you have do the best you can with the little you have.
Garbage mountain metaphor
Garbage removable services are in the business of building mountains, even though it's not what they intended. Write code that is intended to be disposed at some point but because it serves a useful purpose it never gets discarded. Instead other developers pick it up again to add features but don't fix it, thereby adding to the mountain.
Tech debt .
Messy kitchen methaphor
Everytime you make food you should clean up the kitchen. If you defer cleaning for days or weeks, you get bugs in the kitchen and can't find what you need. If you continuously increase your techdebt and never fix the code, it will deteriate as you add features and modify it.
By not keeping your code clean bugs arise.