Hemendra

Why Code Ages — And Why It Needs a Workout

A few weeks ago, I met an old colleague who maintains a fairly large microservice at his company. He sounded frustrated .

“We’re thinking of rewriting the whole thing from scratch,” he said. “Upgrading it will take forever. It’s easier to just rewrite.”

That sentence stuck with me.The service wasn’t crashing. It wasn’t on fire. It wasn’t written in some extinct language. Still, the team wanted to throw it away like a worn-out shoe.

It made me wonder

Why does Code Feel Old?

It doesn’t rust. It doesn’t decay in sunlight. It doesn’t get infected with bugs unless someone writes them. So why do we treat a 5 or 6 year-old codebase like a dying patient?

We forget that writing new code is expensive. Not just in engineering hours, but in lost opportunities: Every rewrite steals time from building new features. Every rewrite delays solving a customer pain point. In an AI-driven world, where new products are born at super fast speed, the cost of slowing down is huge.

And yet… teams still rewrite.

Something deeper is happening.

This makes me think about human body ages. A human body doesn’t suddenly “break.” It breaks when we stop moving. Muscles weaken, joints stiffen, flexibility disappears.

And code isn’t that different. A codebase “ages” when engineers stop understanding it. Its longevity depends on the same things our bodies rely on:

  • Readability is like cardio.

  • Extensibility is like flexibility.

  • Testability is like strength.

If these weaken, even working code feels unusable.

why_code_ages.png

Readability is The Difference between Life and Death

If a new engineer can’t understand your code, your code is already half-dead.

I’ve seen this happen multiple times. Teams change, people leave, and suddenly the new folks stare at old files like they’re ancient inscriptions. The code still runs, but maintaining it feels frustrating.

In the age of AI agents, readability matters even more.If an AI agent can’t read your code, it can’t help you refactor it, fix it, or generate safe patches.

In the past, unreadable code was a burden for the next developer. Today, it’s a barrier to the most powerful productivity tool we have. Messy code doesn’t just confuse humans, it causes AI to hallucinate and suggest hallucinated fixes.

When both humans and machines struggle, rewriting becomes the easier option — even if the old system works fine. Unreadable code doesn’t rot. It just becomes too expensive to understand.

Extensibility means, Can You Replace a Beam Without Rebuilding the House?

Extensibility is the building’s flexibility — the ability to change one part without collapsing the entire structure.

A healthy microservice system lets you do things like: Swap routers or ORMs or middleware with a new better option. Remove a feature without touching ten others

But some architectures grow into dense graphs where everything talks to everything.Pull one piece and everything rattles. Spaghetti code as we say.

When a codebase reaches that point, small changes feel dangerous and danger pushes people toward rewrites.

Testability means, Refactoring with Confidence, it is the real Superpower

Testability is the strength of your codebase — the part that gives you confidence to move things around.

Years ago, I worked with a decade-old C++ game engine. No tests. Zero. Every small change required twenty QA engineers running manual sanity checks. Even after all that, we were never fully confident. Naturally, nobody wanted to touch the core modules. Nobody wanted to refactor anything.We weren’t scared of bugs — we were scared of the unknown.

And when fear becomes the default emotion around a codebase… the rewrite discussions begin.

So, How do You Delay a Rewrite?

Everyone knows the easy answer: “Just refactor regularly.” That’s the same as saying: “Just exercise.” The advice is simple - the discipline is not.

Teams are busy. Deadlines loom. Priorities shift. Refactoring becomes “tomorrow’s problem,” and tomorrow never comes. But the truth is this: Code doesn’t die from age. It dies from neglect.

How to Actually “Exercise” Your Code

The Pre-Feature refactoring Buffer: Don’t ask for refactoring sprints, you’ll never get them. Instead, bake a pre-feature refactor buffer with each feature. Follow the ‘Two-PR’ Rule, Before you add a single line of new logic, submit a PR that only cleans the area. No functionality changes, no test updates—just pure cleanup. It’s is like climbing the stairs daily instead of waiting for a gym day.

Optimize for Deletion: Keep your codebase lean. Instead of layers of abstractions, write code in a way that if a feature dies, you can delete the entire folder without a single error appearing elsewhere. Think of it like shedding body fat without losing muscle. 

Write for the AI Model: Don’t write clever code. It should be so obvious that an AI model can explain it back to you. If LLM struggles to understand it, new engineers will have a hard time as well. Clever code is like lifting heavy weights in the gym without proper form. Your peers are impressed but the end is bitter and injuries are inevitable.

These small habits keep the system moving — just like daily exercise keeps the body alive and mobile.

In the end, code is like us. It doesn’t break all at once. It breaks slowly, silently, when we stop taking care of it. And just like our bodies, the best time to start taking care of it was yesterday. The second best time is today.

The better you maintain it, the longer it lives and the fewer “let’s rewrite everything” meetings you’ll have to sit through.


Note: Parts of this article in the final version were edited by AI