軟件工程中,「稍後再修」為何是最持久的謊言
Why "I'll Fix It Later" Is the Most Permanent Lie in Software
軟件工程中的「稍後再修」往往令技術債長期留存,臨時修補、複製程式碼及延後重構都可能演變成架構負擔或生產事故。技術債常因交付壓力、只顧眼前功能,以及對重構風險的顧慮而累積。作者建議把技術債列入待辦,在修改問題檔案時順手改善,並用工具自動化清理工作。
Imagine this. You are fixing a critical bug in production. You trace the error back to a specific file, scroll down, and find a comment left by a previous developer.
It says: // TODO: This is a temporary hack. Refactor this later.
You check the git blame. The comment is from 2019. The author of that comment was... you.
Welcome to the club. We’ve all left that comment. We’ve all promised ourselves, "I'll just ship this to fix the immediate issue, and I'll clean it up next sprint." But next sprint never comes.
This is the story of how our codebases slowly become haunted houses, and why "I'll fix it later" are the most permanent words in software engineering.
The Loan We Take From Our Future Selves
Technical debt is a great metaphor, but we often misunderstand it. It’s not just "bad code." It’s a financial loan we take out from our future selves (and our teammates) to ship a feature today.
Like any loan, it accrues interest. And in software, the interest rate is brutal.
A quick hack to bypass a slow database query? That might save you 2 hours today. But next month, when traffic spikes and the app crashes, that "temporary" hack will cost the team 3 days of panicked refactoring and late-night rollbacks.
Here is the uncomfortable taxonomy of the technical debt we all create:
Type of Debt How It Starts The Real Cost
The "Quick Fix" "We just need this to work for the demo." It becomes the core architecture. Nobody dares touch it.
The "Next Sprint" "We don't have time to refactor now." The ticket stays in the backlog for 4 years until it causes a P1 incident.
The "Copy-Paste" Reusing a component without understanding it. When the original logic changes, the copy silently breaks in production.
The "Dependency YOLO" npm install a 50MB package just to format a date. A security vulnerability in a sub-dependency brings down the whole build.
A code review is not a proofreading session (The Classic Temporary Fix)
Here is what a typical "temporary" hack looks like in the wild:
javascript
// TODO: Remove this before production.
// We are just bypassing the API rate limit for the demo tomorrow.
if (process.env.NODE_ENV === 'production' && user.isDemo) {
return mockData;
}
// Actual logic below...
The Reviewer: "Looks fine for the demo. Let's ship it."
What happened next: The demo was a success. The ticket to "remove the hack" was created. Then it was moved to the next sprint. Then it was deprioritized. Three years later, someone discovers that a specific subset of production users are receiving fake mockData because nobody remembered the environment variable check.
Why do we do this to ourselves?
It's easy to blame laziness, but the reality is systemic. We do it because:
Business pressure: The PM needs the feature by Friday. The "right" way takes two weeks. The "hack" takes two days.
The "It Works" fallacy: The code compiles, the tests pass, and the user gets their feature. The invisible cost of the mess is deferred.
Fear of the unknown: Refactoring a working (but ugly) system feels risky. What if we break it? It's easier to just build on top of the mess.
How do we stop the bleeding?
You can't eliminate technical debt. Just like a business, you can't run without taking on some debt. But you can manage it.
Make it visible.
Don't just leave a // TODO comment. Create a Jira/Linear ticket for it. Give it a story point estimate. Put it in the backlog so it's tracked. If it's not on the board, it doesn't exist.The Boy Scout Rule.
"Always leave the campground cleaner than you found it." If you have to touch a messy file, clean up one thing before you leave. Rename a confusing variable. Extract a small function. Small, continuous improvements beat massive, terrifying rewrites.Fix it when you touch it.
If you need to add a feature to a module, and that module is a mess, ask for the time to refactor it first. "I can add this feature in 2 days with a hack, or in 4 days with a refactor that makes future features take 1 day instead." Let the business decide.Automate the cleanup.
Use linters, formatters, and AI tools to handle the tedious parts. Let the robots worry about spacing and semicolons so you can focus on architecture.
Let's discuss
I know I'm not the only one who has found a 5-year-old "temporary" fix.
What is the oldest // TODO comment you've ever found in a codebase? Did you fix it, or did you just walk away?
Does your team have a dedicated "Tech Debt" sprint, or is it just a myth you tell juniors?
What's the most catastrophic consequence of a "temporary fix" you've ever witnessed in production?
Let’s hear the horror stories. Because sometimes, the scariest ghost in the machine is the one you created five years ago.
來源:DEV Community · dev.to