Trade-offs and Software Engineering

Rafael Ritter
3 min readJul 6, 2020

According to the dictionary, trade-off is “A balance achieved between two desirable but incompatible features; a compromise.” Put in other words, it means we must sacrifice something in order to gain something else. Trade-offs are limitations imposed by reality — they are reality saying to us: “You can’t have your cake and eat it too! You have to make a choice!”

Trade-offs are present in a wide variety of disciplines. One of the fields in which trade-offs are most applied is economics. In economic science, trade-offs are often expressed in terms of opportunity cost, which is the “The loss of other alternatives when one alternative is chosen.” To take an economic example, consider the decision to invest in stocks, which are risky but have higher potential returns, versus bonds, which are safe but have lower potential returns. Choosing one over the other means trading off between certainty and possible profits. In medicine, an example is the patient trade-off, in which patients need to weigh the possibility of a prolonged life expectancy against possible stressful or unpleasant treatment side-effects. Even board games involve trade-offs. In chess, for example, there is a concept called sacrifice, in which a player gives up a piece with the goal of gaining some benefit in terms of strategy — essentially trading material for positional advantage. The list goes on and on.

Even when we leave the formal fields of study, and enter the realm of personal life, trade-offs are still there. Everything in life involves trade-offs — we simply cannot escape them, they rule life altogether. This stems from the fact that there are limits to our time and energy. If you are spending 5 hours per week hanging out with your friends, that’s 5 hours you could have spent exercising, or 5 hours you could have been working in your business. By choosing to do one thing, you are choosing to take away from another. Essentially, every choice has a cost — and if we want to make better choices, we must be aware of the options we have on the table as well as the trade-offs between them.

You might be wondering what all of this has to do with software. Well, quite a lot, actually. Just like the other disciplines, computer science has its own examples as well. The space–time trade-off shows that a program can often run faster if it uses more memory (e.g., by using lookup tables, memoization, caching, etc.). The CAP theorem states that there is a trade-off between consistency and availability in every distributed data store when a network partition happens. And these are just some well-known, named examples. It certainly does not end here.

In software engineering, just as in life, trade-offs are omnipresent. They manifest from the micro to the macro level. As software engineers and architects, we will have to choose between different options for data types, data structures, algorithms, libraries, frameworks, languages, technologies, servers, databases, messaging systems, patterns, models, designs, architectures, etc. Oftentimes we are trading off “ilities”, such as extensibility and maintainability. There is a trade-off even when choosing whether or not to write a test — some testing levels are inherently more expensive, slower, and more brittle than others, so we shouldn’t be writing all of them equally — we should have a test pyramid.

Precisely because of all this, we engineers must be very conscious. The fact that there are trade-offs does not imply that we are taking them into account; and the fact that we are not taking them into account does not imply that they cease to exist. As software engineers and architects, we are responsible for knowing, understanding, and considering trade-offs in order to make well-thought-out and informed decisions. If we want to be professionals, we need to take into consideration the advantages and disadvantages of each alternative before making a decision — otherwise, that decision becomes short-sighted. Therefore, the degree to which we think about, evaluate and analyze trade-offs in software systems is the degree to which we become increasingly better software professionals.

--

--