That didn't work. Well they couldn't figure out what was wrong. And they spent a long time trying to debug the program.
调试这个程序,那时候当然不叫调试了,然后他们发现了问题。
And a large part of being a good programmer, or learning to be a good programmer, is learning how to debug. And it's one of these things where it's harder.
没人能凭本能做好它,如果你相当一名优秀的程序员,或者想通过学习成为一名优秀的程序员,很重要的一部分就是学习怎么去调试。
You turn on your radio, the radio waves passing by, boom, properly tuned, you detected it.
你打开收音机,无线电波传出来,好好地调试一下,你就检测到它了。
This thing here hints at more sophisticated approaches we'll soon take.
这意味着在不久后,我们将使用一些更高级的,调试方法。
And that's because it's easier to test small things than big things. And it's easier to debug small things than big things.
这是因为对小一点的对象,进行测试比对大一点的对象进行测,试要简单多了,调试也是如此。
This is the place where people typically slip up in debugging. They don't think in advance what they expect the result to be.
实验就推翻了你的假设了,人们在做调试的时候往往忽略了这一点,他们做实验之前并没有想想。
And I'm hoping that today's lecture will help you learn faster. The nice thing, is once you learn to debug programs, you will discover it's a transferable skill.
但是突然成果就会显现出来,你们现在正在慢慢学着呢,我希望今天的课程能帮助你们学的快一点,好的一方面是,一旦你学会了如何调试程序。
an interpreted language is often easier to debug, because you can still see your raw code there, but it's not always as fast.
解释语言调试起来很容易,因为你可以看到最原始的代码,但是这种语言不够快。
PROFESSOR: I want to take a few minutes at the start of today's lecture to wrap up a few more things about debugging.
教授:我想在今天讲座的开头,再花几分钟讲完调试的剩余内容,然后我们再讲主要内容。
The two best debugging tools are the same now that they have almost always been.
最好的两个调试工具一直,以来基本没怎么变过。
And you can use it to debug other complex systems. So for example, a laboratory experience.
你会发现这是一个通用的技能,你可以用它来调试。
It's slow, slow, and you suddenly have an epiphany. And you now get the hang of it.
调试也是很难学的东西之一,学习起来很慢。
For at least four decades, people have been building tools called debuggers.
在过去的至少四十年里,人们一直在做一种叫做调试器的工具。
So one of the things I want you to notice here is that testing and debugging are not the same thing. When we test, we compare an input output pair to a specification.
这里我想大家注意的一件事,就是测试和调试是不同的两件事情,我们测试的时候,我们把输入输出,跟程序的规格说明书对比下。
Does it give you the answer that you expected it to give? Often, in practical problems, you'll spend just as much time doing performance debugging. Why is it slow?
它返回了期待中的结果了么?通常,在实际的问题中你会花,同样多的时间在性能调试上,它为什么运行这么慢?
OK. All right, let me show you one other tool that I want to use. Which is, I've written that piece of code, I ought to check it. Well, I could just run it, but another useful thing to do is, I'm, especially as I want to debug these things, is to simulate that code.
好,那么,让我给大家讲下,我想用的另外一个工具吧,也就是,我已经写好了这一块代码,我应该去检查检查,那么我可以去运行它,但是特别是当我想要调试代码的时候。
Debugging is a different process.
调试就是另外一个过程了。
it's not as good as helping debug, sorry, that's the wrong way of saying it's not as good at catching some things before you run them, it is easier at some times in debugging as you go along on the fly.
它在帮助我们调试方面可能不是太优秀,对不起,这么说有点不正确,它在运行前捕捉错误,可能不是那么优秀,可能边运行边调试,会更容易一些。
You find some way of systematically going through the list. Yet, I often see people, when they're debugging, proceeding at what, to me, looks almost like a random fashion of looking for the bug.
是不是目标元素,我们有一种系统化的,遍历数组的方法,然后我经常看到,有些人调试的时候。
Getting good at this is probably the single most important skill for debugging.
熟悉这一点对调试来说,可能是最重要的技能了。
Algorithms for searching. Debugging is simply a search process.
调试简单点来说,就是一个搜索的过程。
hey'd rather single step it through using Idol or something, than just read it and try and figure things out. The most important thing to remember when you're doing all of this is to be systematic.
比起阅读代码发现错误来他们,宁愿用内置的操作层,或者其他工具一步完成,你要记住的最重要的事情,就是要系统化的去做调试。
About how to debug programs where random choices are being made.
我们会谈谈当程序中,存在随机选择的时候怎么去调试程序。
That, by the way, is also a good debugging tool.
顺便说一下,这是一种很好的调试方法。
That's what distinguishes good debuggers from bad debuggers.
这也是好的调试员和不好的,调试员的区别所在。
Since I'm not sure I won't need to go back to it.
我注释掉了之前的调试语句。
And we're going to talk briefly about testing.
然后也对调试做做讲解。
Alright. Now debugging is a learned skill.
好,发展到现在调试是一门。
In line with what I said about debugging.
这和我在讲调试的时候是一致的。
And I've put it in my debugging code.
调试的代码中去,然后运行看看结果。
应用推荐