How To Reduce Tech Debt to Keep Your Ruby on Rails Application Effortlessly Adaptable
Tags: ruby, rails, codequality
Published: 2024-03-27 21:20:28

---
canonical_url: https://useattr.actor/articles/reduce-tech-debt-entropy
---

Learn how the Second Law of Thermodynamics affects your codebase, and what tidying your workshop has to do with it.

## Entropy, or Why the Pile in the Workshop Keeps Growing

**Entropy** measures the level of disorder or randomness within a system. It's a fundamental concept in physics that explains why things tend to **move from order to disorder over time**, without external intervention. Picture a workshop: this principle manifests as the inevitable clutter that accumulates---tools left out, materials strewn around, each item slightly out of place.


![Illustration of a messy workshop](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4868tfnpyl96jtofj5b1.png)




Just like in a workshop, in software development, particularly with Ruby on Rails, **technical debt** represents this drift towards disorder. It's the buildup of quick fixes and outdated code that, if not managed, makes our applications harder to adapt and maintain. Managing this technical debt is as crucial as keeping a workshop tidy for efficiency.


## The Second Law of Thermodynamics and Your Codebase

The Second Law of Thermodynamics states that, in any closed system, entropy, or disorder, will always increase over time **if no energy is applied to maintain order**. This law, a cornerstone of physics, can be applied to software development as well. A codebase, much like any system, naturally tends towards disorder. Without deliberate effort to refactor, update, and clean up, it accumulates **technical debt**---outdated practices, redundant code, and inefficiencies.

A critical insight for every engineering manager and CTO can be extrapolated: This buildup is a **fundamental principle** at play. Just as energy must be invested to keep a system in order and counteract entropy, consistent effort is required to maintain and improve a codebase, keeping it efficient and adaptable.


## Tidy Up Your Workshop: Strategies for Reducing Code Complexity

If we revisit the workshop metaphor from above, it becomes clear that once entropy kicks in, our tools become harder and harder to find. We have to pick up every gadget, look at it and decide where to put it. This is a tedious process that very closely resembles what we have to do to reduce tech debt and improve adaptability:

- sift through classes for unnecessary coupling and blurred responsibilities
- divide them into more fitting abstractions if applicable, and write tests to verify

But where do you start? This is where [Attractor](https://useattr.actor) can help you with its approachable complexity visualizations and [code vital signs](https://useattr.actor/features).

But there's more. One epiphany that struck me while recently cleaning up my own workshop is: The solution to **finding things** is owning **less stuff**. So I went ahead and threw away any excess material and leftover components that I saved for "later use" (which never happened)---until my workbench was clean:


![Illustration of a tidy workshop](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a8xjpj7adowljsbubtft.png)




How does that translate to code? Well, one proxy metric to measure the amount of clutter is **code complexity**. Use it as a lens to find the most salient places in your codebase to clean up. It's the dust cover on that pile of junk over there---right in front of your favorite sonic screwdriver that you've been missing for so long.

## What Can Attractor Do For You?

In a nutshell, Attractor covers three distinct use cases:

### Ongoing Accompaniment of Development

This is the marquee scenario: By providing continuous reporting and flagging tech debt as it emerges, it helps establish a steady **culture of grooming**. You reap the profits in the form of a sustained development velocity 🚀.

That requires an already pretty tidy environment, though. It might be that you need help cleaning up first 👇.

### Gradual Tech Debt Removal

Chances are, you went the "ship fast, clean up later" route. That's fair! It doesn't make much sense to polish an app before it makes money, I get it.

Slowly, though, you start to feel growing pain. Your domain model feels wrong *in this spot*, because you can't add an association *here*. This form over there feels clunky, but what can you do about it?

Attractor points you to the most painful spots to get a bird's-eye view of where to start weeding.

### Whole-App Refactoring Guide

Maybe you're a consultant being tasked with tidying up the mess that others made. Don't fret!

Attractor helps you split up your refactoring endeavor into manageable chunks and spotlights the most powerful levers to get your app in shape again.