调试秘诀!(一)
软件调试秘诀!(一)
概览
Understanding is everything.
理解整个软件运行是进行调试的基础。
调试的核心步骤:
1. 重现
2. 识别
3. 修复
4. 思索
Reproduce:
Find a way to reliably and conveniently reproduce the problem on
demand.
Diagnose:
Construct hypotheses, and test them by performing experiments
until you are confident that you have identified the underlying
cause of the bug.
Fix:
Design and implement changes that fix the problem, avoid introducing
regressions, and maintain or improve the overall quality of
the software.
Reflect:
Learn the lessons of the bug. Where did things go wrong? Are there
any other examples of the same problem that will also need fixing?
What can you do to ensure that the same problem doesn’t happen
again?
Put It in Action
调试时候请参考
• Make sure to do the following:
– Work out why the software is behaving unexpectedly.
为什么软件并不象预期那样工作。
– Fix the problem.
修复问题
– Avoid breaking anything else.
避免其他地方出现问题。
– Maintain or improve overall quality.
维护和促进总体质量
– Ensure that the same problem does not occur elsewhere and
cannot occur again.
保证相同的问题不在其他地方出现,并且不再发生。(方案会在后面提到)
• Leverage your software’s ability to show you what’s happening.
通过提高软件的能力去显示发生了什么。
• Work on only one problem at a time.
每次只专注于一个问题。
• Make sure that you know exactly what you’re looking for:
确保你精确地知道预期结果是什么。
– What is happening?
出现了什么结果。
– What should be happening?
什么结果应该出现。
• Check simple things first.
先检查简单的事情。
大多数bug都是因为马虎所引起的。请不要忽视简单的事情。
PS:
windows了很久之后才linux的,难受的IDE的调试机制导致不得不去学习很多linux下专有的技能。
当然笔者也用了1年多的linux了。(linux-only)
笔者也是犹犹豫豫了很久,但是作为一个科班的同学不弄linux简直不好意思跟同学打招呼呵。学了之后自然知道进步匪浅。并且现在习惯性的用windows也bash指令出来了。
希望有志者以此共勉之。
这篇文章整理自:
Debug It!: Find, Repair, and Prevent Bugs in Your Code, by: Paul Butcher.
这本书上面的内容不错。有好点的内容,我就分享上来。
水平有限,翻译的不准确,故将原文贴出,希望大家理解。可能前期有耐心的时候还翻译,之后。。。。(你们都懂得)
posted on 2012-01-16 19:18 Richard Wong 阅读(221) 评论(0) 收藏 举报
浙公网安备 33010602011771号