Why You Should Touch The Code That’s “working Just Fine”
Last updated on

You’ve probably heard the saying (or seen the meme):
“If it works, don’t touch it.”
Sounds funny, and sure, it gets a laugh. But if you’ve been in software development for a while—or even just care about writing code that others can read and build on—you know that mindset won’t get you far.
Refactoring is not about fixing bugs. It’s about keeping your codebase clean, scalable, and up to standard. Think of it like cleaning your house—not because it’s falling apart, but because a tidy space helps you live better.
My Recent Example
The image below shows a cumulative Git commit. It’s a rebased commit made by squashing several refactor commits into one, then rebasing that into the main
branch.
What’s special?
It shows that I refactored the Modules/Job
module by 73.5%.
This didn’t just happen randomly. It started when I introduced architectural tests—and they failed. That failure gave me exactly what I needed: signals that the current structure had drifted. As the Chief Architect, I knew if I didn’t refactor now, the upcoming bi-weekly sprints would only stack on top of a shaky foundation.
So I dove in.
What Did the Refactor Involve?
- ✅ Restructuring controllers to follow Laravel’s resourceful conventions, including single-action controllers
- ✅ Aligning the codebase with PSR standards
- ✅ Applying SOLID principles wherever possible
- ✅ Creating a temporary
route.php
file with permanent redirects from old to new route structure (yes, even redirects deserve structure!)
Why Refactor Anyway?
Because every time you avoid it, tech debt grows. You don’t have to refactor daily. But weekly or bi-weekly, especially when code smells start showing? That’s the time. And if you’re interested in learning more about how to refactor well, I’d recommend following Martin Fowler, whose books and posts are a goldmine for understanding refactoring patterns.
Want Your Code Refactored?
If you’ve got a Laravel codebase that could use a cleanup—or even just want a second pair of eyes on it—I’m available for freelance consulting. You can reach out to me on Upwork, and I’d be happy to take a look.