If you were reading a book in your warm bed on a cold winter's day, you might say you were snug as a bug in a rug.
VOA: special.2009.06.28
By putting it in a function bug if I find a bug and I change my program I can just run the function again.
把我输入的值放到一个函数里,如果以后我在程序中发现了一个,并对程序进行更改的话,我可以直接。
Oh, no. Oh, wait. Actually, yes. I bought a painting of a bug, a grasshopper
没有,哦,等等。实际上买过。我买过一幅画着虫子、蝗虫之类的东西的画,
It's a statue of a woman with white robes and long hair. Her arms are thrust high into the sky, and she holds aloft a giant black bug.
VOA: standard.2010.08.10
bug It's not true now. If there is a bug in the program it's there for only one reason.
如果程序中有一个,那一定是有原因的,是你通过例如犯了。
All right, so there's a bug.
好的,这里有一个缺陷。
It's like a bug or something.
这就像只虫子或者类似的东西。
I've had graduate students come to me and say I found a bug in my program.
你该感到自豪么?经常有毕业生,来找到我并告诉我。
bug If you find a bug, it probably means there bug are more of them. So you ought to be bug a little bit careful. The story I've heard told is you're at somebody's house for dinner, and you're sitting at the dining room table, then you hear a .
对不对?你得修复这个,如果你发现了一个,可能就意味着还有更多的,因此你应该小心点,我听说的一个故事,是当你在别人家吃饭的时候,你坐在餐桌上呢,然后听到了邦的一声响。
I have a bug. Alright. Now what do I do?
好,现在我该怎么办呢?
And you'll see at the bottom, bug it says the first actual case of a bug being found.
然后程序就正常工作了,因此这就是第一个被发现的。
We're actually making a legitimate copy with this version of the program so I don't have this bug in anymore.
我们使用这个程序版本,做了一个合法的拷贝,这样我就没有这个bug了。
Let me show you one more class, though about-- sorry, let me show you two more classes of algorithms. Let's look at the next one g- and there's a bug in your handout, it should be g of n and m, I apologize for that, I changed it partway through and didn't catch it.
请大家看,额,在你们的课堂材料中有个错误,应该是g,很抱歉-,我改了一部分这个错误但是没看到这里的,好,这儿的增长率,有人想猜猜么?
Now, should you be proud when you find a bug?
好,那么当你发现一个bug的时候?
So you say well, rather than rushing off and fixing this one bug, let me pull back and ask, bug is this a systematic mistake that I've made throughout the program?
因此我们应该回头想想,这是不是我在整个程序中都,在犯的一个系统性错误,而不是匆匆忙忙的去修复这一个,如果确实是系统性错误的话?
It solves a slight bug if we don't use it at all, but more on that in the future when you talk about files and creating files.
它解决了一点缺陷,如果我不用它,但是更多的是在以后当你们讨论,文件和创建文件时。
Just a few small points. First of all, keep in mind that the bug is probably not where you think it is. Because if a bug were there, you'd have already found it.
第一,记住错误可能不是,发生在你认为的地方,因为如果那儿有一个错误,你可能已经找到了它。
And by just doing that, bug I just spotted, there's a bug here.
我刚刚这么做了,就发现了有一个。
it turns out, that this will be a bug, and I want you to think about why it's wrong for me to put this check here.
结果表明我们这儿有一个漏洞,我希望你们去想一想为什么,我把这个check放在这儿就出现漏洞了。
The goal is to move towards a bug free program.
而是去得到一个没有bug的程序。
Well remember, that I started this with a bug.
请记住,当我知道其中有一个bug的时候。
bug And maybe by understanding why it worked on a and not on b, you'll get a lot of insight that you won't if you just focus on the bug.
发现很多东西,而你只关注,本身的话就发现不了这么多东西,如果知道你的程序至少还对。
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.
是不是目标元素,我们有一种系统化的,遍历数组的方法,然后我经常看到,有些人调试的时候。
And that does two things: bug one, it helps catch bugs in your code, and secondly it often converts it into a more efficient sequence of instructions before you actually go off and run it. All right?
这有两点好处:,第一是可以帮助你发现程序中的,第二是把你的代码,在运行之前,转换为更有效率的指令的集合,对不对?
So you try and find a smaller input that bug will produce the problem.
你应该尝试着用规模小一点的输入,去重现这个。
bug You put it there. i.e. you made a mistake.
一个错误这种方式来制造了这个。
Initialization. A very common bug is to initialize a variable. Go through a loop, and then forget to reinitialize it when it needs to be reinitialized again.
忘记初始化,忘记初始化变量是一个很常见的错误,运行完一个循环之后,当需要再次初始化时。
So I've got one more piece of bad code on this point and this is buggy five dot c. So as a comment on top bug of this file challenges, what is, in fact, the bug.
所以我在这里得到了一块很烂的代码,这个是buggy5,c,所以作为这个文件顶端的注释,那实际上是那个。
In Python, it'll find it, I think one bug at a time, right John?
在Python中,它会找到它的,我觉得一回能找一个漏洞,对么John?
应用推荐