技术债务
所有持续拖慢软件开发的东西,都可以视为技术债务。
显示原始英文内容
Technical Debt
Technical Debt is everything that slows us down when developing software.
Takeaways
- When we take a shortcut in code, we borrow time from the future. This gives an immediate benefit, but you owe principal (the work to fix) plus interest.
- If technical debt is not repaid, it accrues interest. Each minute spent on dirty code, bugs, and workarounds due to a lack of refactoring is interest on the debt.
- Not all technical debt is inherently bad. It is sometimes necessary, for instance, for market timing or prototyping.
- The way to pay down technical debt is to refactor code, add missing tests, and improve design.
Overview
Technical debt highlights a fundamental tension in software engineering: speed vs. quality. The term helps explain to both developers and non-technical stakeholders why seemingly "done" software still needs ongoing work. When you write clumsy code or postpone cleanup, you've essentially taken out a loan: you get short-term feature delivery, but the complexity you introduce is the interest you'll keep paying.
Properly managing technical debt means being conscious of when you're adding a quick workaround or a "temporary" hack, and having a plan to revisit it. Teams often use tools to log technical debt items (like comments, issue tracker tickets, or dedicated debt backlogs).
When managed, technical debt can be an effective tool; you intentionally take on a bit of messiness to get feedback or meet a deadline, then clean it up. But if ignored, debt becomes a problem.
Examples
A typical example is skipping automated tests. A team under deadline pressure releases a new feature without writing tests. The release is successful (debt incurred). But later, making changes becomes harder since every change risks unforeseen bugs because there's no safety net of tests (interest payments). Eventually they must stop adding features and fix the debt by adding the missing tests and refactoring.
Another example is a startup that wants to deliver a quick prototyping effort to onboard the first customer. Developers do rapid but messy coding, with hardcoded variables and copy-and-paste code. This approach is made with technical debt in mind. The endeavor helps the startup win a customer; however, the startup's codebase is now full of technical debt.
If they just continue to add to it, they will face bugs and slower performance due to the messy code (interest on debt). They realize this and therefore set up a "rehab" sprint to refactor the code, thereby resolving the most troublesome bits.
Origins
The term "Technical Debt" was coined by Ward Cunningham (one of the authors of the Agile Manifesto) at the OOPSLA conference in 1992. He first used the financial metaphor while working on a finance application to explain to his boss why the team needed time to refactor code.
Ward compared developing software to borrowing money: it can be wise to take shortcuts (borrow) to achieve something sooner, provided you pay back the loan by cleaning up the code later.
核心含义
为了速度、确定性或临时验证而接受的设计妥协,会在未来通过更慢的开发、更高的缺陷率和更大的变更风险产生利息。技术债务不只是丑陋代码,也包括过时依赖、缺少测试、脆弱流程和不清晰的架构。
债务并不总是错误,关键是显式记录、评估利息,并在合适的时机偿还。
实践例子
团队为了赶上线把手工部署和临时脚本留在生产环境。早期节省了时间,但每次发布都需要熟悉细节的人介入,最终成为交付瓶颈。
来源与边界
Ward Cunningham 用金融债务比喻设计妥协。不要把所有不喜欢的代码都贴上“债务”标签;真正的债务应当能说明它如何影响未来工作和风险。