root-cause-fix
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRoot-cause-fix
根因修复
Fix the first wrong decision, not the place where the failure showed.
- Reproduce it, on the real surface when you can. Read the actual state. Do not guess from the code.
- Ask what changed. Compare with the last version that worked. Check whether the base is already broken before you blame the change.
- Ask "why" until the answer is a wrong decision in the code or in the design. A guard, a retry, a fallback value, a swallowed error or a poll at the place of the symptom hides the fault, unless the state that it handles is legitimate.
- Fix the pattern. Find every place with the same fault.
- When two fixes that share one assumption fail, the assumption is wrong. Test it directly, or give the problem to a fresh reader with no context.
- Say the cause in one sentence. If you cannot, you have not found it.
修复第一个错误决策,而不是暴露失败的地方。
- 尽可能在实际使用场景中复现问题。读取实际状态,不要根据代码进行猜测。
- 询问发生了什么变化,并与上一个能够正常工作的版本进行比较。在归咎于当前改动之前,先检查基线是否已经损坏。
- 不断追问“为什么”,直到找到代码或设计中的错误决策。在症状出现的位置添加 guard、retry、fallback value、吞掉错误或使用 poll,只会掩盖问题,除非它所处理的状态本身是合法的。
- 修复问题的模式。找出所有存在相同错误的地方。
- 如果两个共享同一假设的修复方案都失败了,那么这个假设就是错误的。直接验证它,或者把问题交给一位不了解上下文的全新读者。
- 用一句话说明原因。如果做不到,说明你还没有找到根因。