Code Quality Basics - What Is Technical Debt?


Image Image


As you make enhancements to your source code, how do you ensure that you are adhering to all the standards? Is there a way to measure how good your projects is? What is Technical Debt?

You will learn

  • What is technical debt?
  • What are the challenges with having large technical debt?
  • Why should reduce technical debt?
  • How do you track technical debt?
  • How do you deal with technical debt for old projects?
  • What are the best practices with handling technical debt?

Free Courses - Learn in 10 Steps

Article Series

This is first article in a series of 6 articles on important code quality terminology:

What is Technical Debt?

Not all applications are designed and developed well. The gap that exists between the design and the code of your application, as compared to an ideal application, is called technical debt.

Amount of additional effort we have to put in future development and maintenance, in order to make up for the bad choices we made, and the shortcuts we took during initial design.

Making short-term bad decisions to meet deadlines can lead to technical debt.

Writing bad code, or code that is not supported by unit tests, can lead to technical debt.

Measuring Technical Debt

It is impossible to measure technical debt accurately. Its at best, a quick guess or a means comparison between projects.

Typically the aim of estimating technical debt is not to come up with an absolute measure of the cost, such as USD 1 Billion or something similar.

The aim is to categorize your application within a set of other applications. For example, “among this given group of applications, the technical debt of your application is low”.

Tools to measure Technical Debt - SonarQube

A popular tool used to give estimates of technical debt is SonarQube:

image info

You can see that the categories of technical debt parameters are:

  • Bugs : How many bugs are present in the code base?
  • Vulnerabilities : For example, what are security vulnerabilities of your program?
  • Code Smells : These describe the coding good practices that are not being followed.
  • Coverage : How many unit tests do you have, and how many lines of the total code do these tests cover?
  • Duplication : How many times are specific blocks of code repeated?

These parameters are a direct measure of application code quality as well. SonarQube calculates each of these parameters, and then estimates the technical debt that arises out of each of these.

Running SonarQube Periodically

When SonarQube is part of your Continuous Integration process, technical debt can be continuously tracked

Sometimes in a large project, it may not be possible to reduce the existing technical debt. However, it might be possible to tighten your practices to make sure you don’t add fresh debt to your burden.

If you look at the Code Smells section of the SonarQube, it also measure newly introduced technical debt.

Reducing Technical Debt

Include Technical Debt in Definition of Done and monitor it during every sprint.

The things that you can do to reduce technical debt that you detect, include:

  • Keep Architecture Simple. Make use of the Four Principles of Simple Design extensively in your application.
  • Perform Continuous Refactoring. For this, you need to have the confidence to change the code, which comes from the next point.
  • Have Great Unit Tests. They ensure that breaks and bugs in code can be detected and fixed.
  • Follow Test Driven Development (TDD). Here, you write tests before you write the code, and these lead to good design.
  • Perform Static Analysis Periodically. We saw an instance of this in SonarQube, especially when used as part of CI.
  • Perform Regular Peer Reviews. Static analysis can find only certain kinds of defects. It cannot find things such as bad variable, class and method names. This is very essential to ensure readability of code.
  • Maintain A Technical Backlog. Keep a list of things that you need to fix, and prioritize them regularly.
  • Have Periodic Cleanup Sprints.

Challenges With Technical Debt

Improving An Existing Project

A big challenge with technical debt, is figuring out how to improve an existing project having a large debt. The following few steps can make this daunting task, a little simpler.

  • Identify Potential Areas Of Improvement. You can analyze the data that you get from static analysis and other means, and identify specific areas to improve the technical debt.
  • Identify Areas OF Future Change. You could also identify the areas of the project, where changes anticipated in say, the next 6 months.

Combine the information from the above two points, and write unit tests for the areas of anticipated change for the next 6 months. This is very important, because we don’t want to introduce bugs due to our changes, that go undetected.

Refactor. With the confidence of having unit tests in place, go head an refactor over a period of time.

Build the test base over a period of time.

Technical Debt Best Practices

Have Technical Debt As Part OF Definition Of Done

In each of the Sprint cycles of a project, do a measure of the technical debt, and add action items to a technical backlog.

Measure Technical Debt From Inception

Make sure that you measure project technical debt from day one of the project. There should be a focus on maintaining a low technical debt for the application. This means you do it for a prototype, and you do it for a vertical slice as well!

Do check out our video on the same topic:

image info

Summary

In this article, we had a reasonably close look at the concept of technical debt. It is a qualitative measure of the amount of effort required to take the current design state of an application, close to an ideal application. Technical debt can arise due to reasons such as bad design standards, design shortcuts, incorrect technology and bad coding practices.

Technical debt slows down productivity. It is important to measure technical debt using static analysis tools such as SonarQube. Measuring technical debt needs to be a continuous process. Once monitored and measured, specific steps can be taken to ensure it is reduced and that new debt does not pile up.

Related Posts

Docker Tutorial for Beginners - with Java and Spring Boot

Learn about Docker - What is Docker? Why Is Docker Popular? How to create Docker Image for a Java Spring Boot App?

Devops Tutorial | DevOps with Docker, Kubernetes and Azure DevOps

What is DevOps? How is it different from Agile? What are the popular DevOps Tools? What is the role of Docker, Kubernetes and Azure DevOps in DevOps. Let's get started with a simple usecase.

Deploy Java Spring Boot Applications to AWS, Azure, GCP with Docker and Kubernetes

In this article, we focus our attention on the cloud. How to learn the cloud and deploy Java Spring Boot Applications to AWS, Azure, GCP with Docker and Kubernetes?

Spring Boot Tutorials for Beginners

At in28Minutes, we are creating a number of tutorials with videos, articles & courses on Spring Boot for Beginners and Experienced Developers. This resources will help you learn and gain expertise at Spring Boot.

Microservices with Spring Boot and Java - Part 1 - Getting Started

Let's learn the basics of microservices and microservices architectures. We will also start looking at a basic implementation of a microservice with Spring Boot. We will create a couple of microservices and get them to talk to each other using Eureka Naming Server and Ribbon for Client Side Load Balancing. In part 1 of this series, lets get introduced to the concept of microservices and understand how to create great microservices with Spring Boot and Spring Cloud.

20+ Spring Boot Projects with Code Examples

At in28Minutes, we have created more than 20 projects with code examples on Github. We have 50+ articles explaining these projects. These code examples will you learn and gain expertise at Spring Boot.

REST API Best Practices - With Design Examples from Java and Spring Web Services

Designing Great REST API is important to have great microservices. How do you design your REST API? What are the best practices?

Index - 500+ Videos

At in28Minutes, we are creating a number of tutorials with videos, articles & courses on Spring Boot for Beginners and Experienced Developers. Here's a list of video tutorials and courses for you

Creating Spring Boot and React Java Full Stack Application with Maven

This guide helps you create a Java full stack application with all the CRUD (Create, Read, Update and Delete) features using React as Frontend framework and Spring Boot as the backend REST API. We use Maven as the build tool.

Creating a SOAP Web Service with Spring Boot Starter Web Services

Let's learn how to create a SOAP Web Service with Spring Boot Starter Web Services. We will take a Contract First approach by definining an XSD and exposing a WSDL from it.

FREE COURSES



in28Minutes Best Selling Udemy Courses

Image Image Image Image Image Image Image Image Image

450,000 Learners are pursuing our 31 amazing courses and 6 Learning Paths. Start Now!

Join 450,000 Learners and 30+ Amazing Courses

LEARN DEVOPS - 200+ VIDEOS - Master DevOps with Docker, Kubernetes and Azure DevOps


350,000 Learners are learning everyday with our Best Selling Courses : Spring Boot Microservices, Spring, Spring Boot, Web Services, Hibernate, Full Stack React, Full Stack Angular, Python, Spring Interview Guide, Java Interview, Java Functional Programming, AWS, Docker, Kubernetes, PCF, AWS Fargate and Azure


85,000 Subscribers are learning from our Free Videos on YouTube : JSP Servlets, Spring, Spring Boot, Spring MVC, Hibernate, Eclipse, Maven, JUnit, Mockito, Full Stack - React, Full Stack - Angular, Docker, Kubernetes, AWS, AWS Fargate, PCF and Azure


Here are the recommend articles to read next : Spring Interview Questions, Spring Boot Interview Questions, Microservices, Hibernate, Spring Security, REST API with Spring Boot, Full Stack with React, SOAP Web Services, Exception Handling, Embedded Servers, Spring Data Rest, Spring vs Spring MVC vs Spring Boot, Building Web Application and Spring Data JPA.

You can checkout all our 100+ articles here - All Articles.


Do not know where to start your learning journey? Check out our amazing learning paths:
Learning Path 01 - Spring and Spring Boot Web Applications and API Developer,
Learning Path 02 - Full Stack Developer with Spring Boot, React & Angular,
Learning Path 03 - Cloud Microservices Developer with Docker and Kubernetes,
Learning Path 04 - Learn Cloud with Spring Boot, AWS, Azure and PCF and
Learning Path 05 - Learn AWS with Microservices, Docker and Kubernetes


Subscribe