How to Deal with Technical Debt: strategies and tips
Tags: architecture
Published: 2021-03-30 14:47:17

We’re all familiar with the concept of financial debt. Borrowing money means you can accomplish more now, but at a higher cost later. To use a common example, let’s say you want to break into the housing market. Chances are you don’t have the cash to purchase a property outright, but prices in your area are rising and you want to buy a home before it becomes too expensive. Taking out a mortgage would make it possible for you to do so, but you’re going to pay for that privilege later, in the form of interest on your loan. When we talk about technical debt or tech debt, we’re applying that concept to software development.

![Alt Text](https://media.giphy.com/media/11sN6nMjLT2INO/giphy.gif)

<h2>What is technical debt?</h2>

The name is no mistake, as it works in a similar way to financial debt. When you take shortcuts to roll out a product on time, you basically take on debt. If you don’t pay it off before moving on to the next stages of the product, your work will become a lot harder, and you’ll likely be forced to take on even more debt as you move forward.

Basically, the more debt you take on, the more it slows down the development process, and the more you will have to take on as you move on to developing every new feature.

The term technical debt can be applied to any technical solution that is suboptimal in any way. The most important thing to know about it is, it’s unavoidable.

The reason for it is fairly straightforward: whenever there are a number of solutions at hand for a problem, they tend to have different upsides and downsides, so all solutions are suboptimal in some way.

The best software engineering teams are not the ones who aren’t stacking up tech debt; such a situation doesn’t exist. The best teams are great at managing technical debt.

<h2>Why should you care about technical debt?</h2>

<h3>How tech debt affects developers</h3>

Developers have to deal directly with technical debt, so while it may make their job easier today, it will certainly make it a lot harder and more time-consuming in the long run. It could be beneficial to take on some technical debt to hit deadlines, but efforts should be made to avoid unintentional and reckless debt.

<h3>How tech debt affects clients</h3>

At first glance, it may seem like clients have no reason to care about the code quality of a product as long as it works, especially when the possible trade-off could be a delay and increased development cost. However, a project loaded with technical debt will require far more time, effort, and maintenance costs when it comes to future development. This extra cost is likely to significantly surpass the initial gains.

![Alt Text](https://codingsans-website-assets.s3-eu-west-1.amazonaws.com/public/uploads/images/techdebtcost.png)

Source: martinfowler.com

<h3>How tech debt affects users</h3>

The users are also affected by technical debt, even if indirectly. They may not care about the amount of work or money that goes into software, but they do care about it working reliably, and about new features being added at a rapid pace, both of which could be set back by a lot of technical debt. The happier users are, the happier the client is, and the happier the devs are allowed to be.

<h2>Best practices to prevent technical debt</h2>

![Alt Text](https://media.giphy.com/media/xT0xeNRxjPDexpjO9O/giphy.gif)

The single biggest problem in technical debt reduction is that it’s not really quantifiable. That makes it hard for the software developer team to track and demonstrate to the business side how it’s an issue worth spending resources on. Your best bet is to prevent tech debt from overtaking the code base.

Here are a few ways you can do this:

<h3>Be up-to-date</h3>

It should go without saying that tools, frameworks, and libraries should always be kept up-to-date, but it never hurts to state, as it may not be obvious for everyone.

<h3>Documentation</h3>

Documenting everything that needs fixing or updating is the most essential step toward making sure they actually get fixed and updated.

If there is technical debt, it’s best to be aware of it and to make sure the team or future developers are aware as well. It reduces the effort required to locate and fix any issues, and if the debt is well-documented, it may even be visible on the business level, causing clients to acknowledge it and provide extra resources to combat it.

<h3>Code reviews</h3>

Another powerful tool is to regularly have new code reviewed by peers during a sprint. Another set of eyes could catch solutions that may cause problems down the line. It does take some time out of sprints, but it will certainly be worth it in the context of an entire project.

However, code review has its downside too. Developers are often too busy to dig really deeply into others’ codes, so they only really spot glaring mistakes, and nitpicking is likely to lead to tension within the team. So, it can be a powerful tool in minimizing technical debt, but it should be applied carefully. 

<h3>Automated testing</h3>

Automated testing is an extremely powerful tool too often disregarded. However, when it’s neglected, it becomes incredibly risky and hard to change anything in large bodies of code. It leads to features that can’t be implemented, or only at extreme cost, by putting in disproportional amounts of manpower and working hours.

It is worth the effort to create tests and testable code. It is worth considering implementing practices like test-driven development (TDD), it could get rid of a lot of problems with code.

<h3>Agile architecture</h3>

Agile architecture has a lot of advantages, being more open to changes when in the process of building the software, which is basically guaranteed to happen on any project. However, it does require the code to be flexible and maintainable, so the Agile approach will naturally make developers keep the code and its structural quality in good shape, which helps prevent the accumulation of massive technical debt.

<h2>Best practices for managing technical debt</h2>

![Alt Text](https://media.giphy.com/media/d2ZfsyuPQ18nypVK/giphy.gif)

Even if you do all the above, and avoid stacking up tech debt as much as possible, you will still have to deal with some. It can’t be avoided, so you should implement practices and processes for technical debt management.

<h3>Refactoring high-interest technical debt first</h3>

Not all tech debt is created equal, so you should prioritize what to address, and what not to address, at any given time. Cruft at a part of code that is used and changed often is far more important than cruft at a part that is barely ever used or changed.

It’s high-interest debt because there is a lot of work done around it and based on it. So long as it stays in place, debt hampers all the work, and likely forces more tech debt to be added to other parts of the code. So whenever possible, these issues should be prioritized first, making everything smoother in the long run.

<h3>Boy Scout rule - Continuous refactoring</h3>
The rule for Boy Scouts is to always leave the campsite in better shape than you found it. It translates to software development in a way to always fix technical debt when you find it.

Naturally, it can’t be done without boundaries, or else it could consume all the time in the world. However, if you set aside a percentage of time in each sprint specifically to fix any tech debt developers may find, continuous refactoring goes a long way towards keeping the product as debt-free as possible. Depending on the situation, anywhere from 5-33% could be a good choice.

<h3>Just ignore it</h3>
It’s also important to note that technical debt should not always be repaid. When a product is near the end of its life, if it’s built for a short cycle or if it’s a throwaway prototype, technical debt is not a major concern. These instances are few and far between, but you can save some time and effort when they do come up.

<h2>Conclusion</h2>

Technical debt is an issue for everyone in the software development industry, but regrettably, there is no silver bullet against it. Keeping it at bay and avoiding its potentially crippling effects takes a lot of thorough work, strong coding principles, and well-set-up work processes.

I hope this information helps you to be more prepared the next time you take on a project.