💠Solve Problems and Improve your Code with Subtraction
When it comes to solving problems, our first instinct is addition, but removing code or features can be much more beneficial in certain situations.
Last week I listened to the latest episode of the People I (Mostly) Admire podcast, where Steven Levitt interviews Leidy Klotz, the author of Subtract, about the power of subtraction. The main argument is that we are awful at using subtraction instead of addition when considering how to improve a system. I didn't read the book yet, but I definitely have to. The main argument reminds me very much of the Via Negativa heuristic Nassim Taleb mentions in one of his books.
Immediately, this reminded me of software development, too. For example, when we run in situations where we know that we should remove a particular piece of code but aren't confident enough about our knowledge about the system to do so. Or when, after a refactoring, we end up with fewer lines of code that make a more stable implementation. Furthermore, we can improve many systems, both from a UX point of view as well as helping to remove lines of code, by eliminating confusing or obsolete features.
A more concrete example: One of the main things people complain about when writing CSS the traditional way is that CSS only grows over time, but nobody ever dares to remove anything. This is a big argument for utility-based CSS. I think this shows how important it is to enable and encourage subtraction to keep our code maintainable.
When it comes to CSS, utility-based frameworks like Tailwind can be an option. But there are also other approaches like CSS-in-JS or the good ol' BEM convention that help with giving us more confidence about what we can remove safely.
The best way to make our websites faster is to remove things—for example, images, CSS, or, most pressing, a few 100 kilobytes of JavaScript.
When it comes to regular code and business logic, having excellent tests is the only way to guarantee that we can remove code with confidence. This shows that adding things also has its place. Adding a good test can help us a great deal when it comes to removing code at a later stage of the life cycle of an application.
We should train ourselves always to remember that subtraction is an option when it comes to making improvements to our applications. Not only in terms of improving the codebase but even the usefulness and UX of the whole application itself.