• I'm not going to do it for you, but what would I think about doing when I change the code?

    要改变代码应该做什么呢?,不会帮你们做这些,但是改编代码的时候会想什么呢?

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • And notice because I have just one line of code inside of each of these branches, what have I clearly omitted?

    请注意因为每个分支中只有一行代码,显然地省略了什么?

    哈佛公开课 - 计算机科学课程节选

  • And in the process of tidying it up and making it prettier, I'll often by accident find the bug.

    的程序更漂亮些,这个清理美化代码的过程中,常常无意中发现的错误。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • What happens now after we've executed this third line of code, what happens next in the story?

    执行完第三行代码会发生什么呢,这之后会发生什么呢?

    哈佛公开课 - 计算机科学课程节选

  • I was being a little lazy on Wednesday in the interest of simplifying the code as much as possible.

    周三那个网站上尽可能地,简化代码的时候,有点偷懒。

    哈佛公开课 - 计算机科学课程节选

  • Right. If you look at the rest of that code, gee, it looks a lot like what I had elsewhere.

    好了如果你看看剩下的代码,天呐,看上去就像别的地方写过的。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • I want the function, which is a little tool, a line of code I can include in my own programs and generally those tools live in sections two or three of the manual.

    想要一个函数,那是一个小工具,在我程序中可以包含的一行代码,通常这些工具手册的第二节,或第三节。

    哈佛公开课 - 计算机科学课程节选

  • Let's assume, for sake of argument, the thing I'm looking for is bigger than this. In that case, I'm going to throw away all of this, I'm going to hit that bottom line of that code.

    们假定不是,假定要找的元素,比这个大,这样的情况下,这些都擦掉,要运行到代码的最后一行。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • Code is right here. And all it's doing is when I'm getting into the different places I'm simply printing out information about where I am. What I want you to see palindrome is notice what happened here.

    代码这儿,它的作用是当运行到不同地方时,就输出方位的信息,想让你们看的就是注意这儿发生了什么,好了调用了一个。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • And to see that I've written another version of this, which I'm going to use here, where I'm going to give it a little indentation.

    已经写另一个版本的代码,将把它用这儿,这儿加一点儿缩进。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • But I got a couple of other of these strange looking things in there with underbars to them.

    可以这片代码中看到这些,然后需要一些可以给,返回这些信息的东西,但是这里还有一些看起来。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • What does that say? It says if in the code up here I get an exception of that sort, I'm going to go to this place to handle it.

    这意味着如果代码中,得到一个这样的异常,能到这里来处理它。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • And henceforth I'm gonna start calling these tools, these monickers that I can use as building blocks in my own program, it's gonna be called a function as we'll see.

    从此以后,在我的程序里把这些工具,称为们可以用来写代码的组件,在我自己的程序中,们将了解到它被叫做为一个函数。

    哈佛公开课 - 计算机科学课程节选

  • Which is a way of reminding you that I need to think as I write the code about what are my expectations from the input, and how might I enforce them.

    通过这个提醒大家,代码的时候,要搞清楚对输入的期望,并思考下如何执行这些期望。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • And I'll sit there staring at the output, staring at the code, not realizing that that output was not produced by that code.

    然后就坐那儿盯着输出的结果,看着代码,没有意识到输出的结果,并不是由代码产生。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • Suppose I want to compute square roots a lot of places in a big chunk of code.

    假设一大段代码中,计算很多次平方根。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • Because if I don't specify a name for this input, I have no way of actually referring to it in subsequent lines of code.

    因为如果不给这个输入定义一个名字,随后的代码中,就没有办法使用它。

    哈佛公开课 - 计算机科学课程节选

  • Well there are a couple of interesting intermediate values here, right? There's tmp.

    回去再看第一段代码,那么这里该关注什么呢?

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • This also, by the way, in some sense, gives me the beginnings of my comments for what the structure of my code is going to be.

    顺便说一句,某种意义上这也是,对于代码结构的,讲解的开始。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • I want to just use it, I shouldn't have to worry about what variables I use inside of it, I have shouldn't have to worry about where that is in the code, I should be able to just abstract it away. And that's what we want to add today, are those two things.

    只是想使用它,不用考虑这段代码中,使用的是什么变量,完全不用考虑代码的内容,只要抽象就好,们今天想补充的内容就是这两点。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • I didn't have anything in there that says, if you change one of these values, other values depend on it, and I want to make that change to it.

    这样就对了,因为代码里面,没有任何的东西说,如果改变了其中的一个值。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • Inside the curly braces is this program's code, what am I doing?

    花括号里是这个程序的代码做什么?

    哈佛公开课 - 计算机科学课程节选

  • Another way of saying it is, anything that uses get float doesn't care what the details are inside or shouldn't, and if I change that definition, I don't have to change anything elsewhere in my code, whereas if I just have the raw code in there, I have to go off and do it.

    换种说法就是,任何用到获取,输入这个功能的人不用担心具体的实现细节,如果改变了这里的实现,并不需要去改变代码,因为的最底处的源码就这里,去改这里就可以了。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • I stress it in particular because I know you're all going to get into this stage; you've got a problem set due in a couple of hours, you're still writing the code, you don't want to waste time, and I'm going to use quotes on "waste time", doing those extra things to do the defensive programming, you just want to get the darn thing done.

    特别强调了这一点,因为知道你们都会慢慢成为程序员;,你代码过程中造成了一系列的错误,你还代码,你不想浪费时间,想把“浪费时间“用引号圈起来,浪费时间来做因为防卫性程序设计,而带来的这些额外的事情,你只想赶紧把程序写完,这不是一个好习惯,因为当你做完回头。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • And what line of code am I on now?

    代码的哪一行呢?

    哈佛公开课 - 计算机科学课程节选

  • Remember last time, I said that there's different kinds of complexity in our code, and I suggested for simple branching programs, the amount of time it takes to run that program is, in essence, bounded by the number of instructions, because you only execute each instruction at most once.

    但是这里有个很重要的点,记得上节课,提过在我们的代码中,有不同种类的复杂度,而且还说了对于简单的分支程序,运行这种程序需要的总体时间,大体上,是和指令的数目相关的,因为每个指令只会被执行最多一次。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • And I suggest two things, right?

    这儿的代码干了两件事情对不对?

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • I can't give it what it wants," know that when you're writing code and the problems that will remind of this, if you absolutely have to kill your program, you don't have to close the window, CTRL+C reboot crazy stuff like that, generally you can hit CTRL+C and it will just abort the program right where it is, in case you ever get trapped in some awkward situation.

    不能给它所要的“,当你代码时,程序将,提醒这个问题,如果你不得不,关闭这个程序,你不需要关闭这个窗口,重启像那样的疯狂举动,通常你可以敲,它将会这个地方终止那个程序,假使你陷入了尴尬的处境。

    哈佛公开课 - 计算机科学课程节选

  • And in fact, if we just go ahead and run this now, hopefully we get out-- oops, sorry, I'm going to have to change this quickly, I still have some things uncommented at the bottom, yeah, there they are, I don't think we need that yet, all right, we will comment those out.

    如果们现去运行程序的话,希望们会得到-噢,抱歉,得去马上,改下代码,还有一些底部的东西没被注释掉,对,就这儿了,不认为们需要,这些东西了,好,们把它们注释掉,好,那么为什么要讲这些呢?

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • If I go back to that code from a moment ago, and I just rerun math3, notice how many places printed after the decimal point -- two?

    如果刚才回到那段代码中去,们回到math3,请注意小数点后面,会打印几位数呢--两位?

    哈佛公开课 - 计算机科学课程节选

$firstVoiceSent
- 来自原声例句
小调查
请问您想要如何调整此模块?

感谢您的反馈,我们会尽快进行适当修改!
进来说说原因吧 确定
小调查
请问您想要如何调整此模块?

感谢您的反馈,我们会尽快进行适当修改!
进来说说原因吧 确定