I'm not going to do it for you, but what would I think about doing when I change the code?
要改变代码应该做什么呢?,我不会帮你们做这些,但是我在改编代码的时候会想什么呢?
The structural moment of concentration on the code for its own sake cannot be avoided, and literature necessarily breeds its own formalism.
集中在代码上的结构瞬间,因为它本身的原因不可避免,文学必要地导致了它自身的形式主义。
I'm going to start somewhere near the middle of the code. Again, a lot of times, people don't do that.
我会在代码中间的某个位置开始,再说一次,很多时候人们不会这么做。
And notice because I have just one line of code inside of each of these branches, what have I clearly omitted?
请注意因为我在每个分支中只有一行代码,显然地我省略了什么?
Honor to so many of us sounds quaint, like an honor code or the Boy Scouts' code or something like that or something primitive, some kind of primitive ethic which we therefore don't really understand.
荣誉,对我们中大多数而言,听起来都会很奇怪,这就像是在说荣誉代码,童子军守则或一些类似的东西一样,亦或是一些非常原始的理论,以致于我们根本不知道这是在说什么。
So, inside of code, or inside of a script, there's no print, unless we make it explicit.
因此,在代码里面,或者在脚本里面,不会有显示结果的功能,除非我们让它这么做。
Right. If you look at the rest of that code, gee, it looks a lot like what I had elsewhere.
好了如果你看看剩下的代码,天呐,看上去就像我在别的地方写过的。
What happens now after we've executed this third line of code, what happens next in the story?
我执行完第三行代码会发生什么呢,在这之后会发生什么呢?
So at this point, now the code's getting a little more interesting, but it's also getting a little bloated.
所以在这里,现在代码变得更有趣了,但是它也显得有点臃肿。
You've got to do it above this chunk of code, you've got to do it inside this chunk of code.
你不得不在一大段代码之上来实现它,你不得不在一大段代码之内来实现它。
It ultimately evaluates that line of code but just once the stuff inside the curly braces, but the semicolon on the end, essentially has the effect of this.
它最终执行了那行代码,但是只有一次,当那个东西在花括号里,分号放在后面,本质上影响了这个循环。
In general, good programming style says you put in comments that are going to be valuable in helping you as a reader understand what's going on inside of the code.
通常来说,优秀的编码风格意味着,你要放进去的注释,在帮助代码阅读者,理解代码内部,是怎么工作的。
But thankfully now in 2010, we're at the point where there's a whole lot of free and open source software that you can integrate into your projects that other nice people have made available.
不过幸好在2010年,现在有很多可用的开源,代码软件,你可以将其融合,到你的工程中。
Now we're gonna hand you some framework, that code that we wrote with some blanks to get you accustomed to the idea of one, writing larger programs than time might allow if you were doing it on your own.
现在就提供给你们一些框架,在代码中有些空白,是为了让你们了解其中的思想,如果是你自己,若时间允许,那就尽量写大的程序。
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.
这意味着如果在代码中,我得到一个这样的异常,我能到这里来处理它。
So if you're coming from prior background, your code might work a little differently on a different system if you don't use those flags.
如果你来自一个先前的背景,如果你们没有使用这个版本标志的话,在一个不同的系统中,你的代码可能运行地不太一样。
So, it frees you from some of Apple's tethers and this was the code that circulated on the Internet iPhone with which people could crack their iPhones.
这样我们就从苹果的约束下解放出来,这些代码是在网站上流通的,使用它们可能损坏你们的。
Because there will not be time to look at that code for the first time during the quiz, and figure out what it's doing.
因为在考试中,是没有时间去第一次看代码,并弄懂它的意思的。
Give you some examples. What have we talked about? We've talked about things like using comments to highlight what you're doing in the code, to make it easier to debug.
给大家举些例子,我们一直在强调什么来着?,我们讲过要用注释来说明,你在代码中进行的操作,以便于调试。
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?
这有两点好处:,第一是可以帮助你发现程序中的,第二是把你的代码,在运行之前,转换为更有效率的指令的集合,对不对?
And so what I was hinting at earlier when you put semicolons in the wrong place, and then proceed to have curly braces around arbitrary lines of code, you're creating an even more local scope there, which is generally not the right intended behavior.
在之前我暗示了,当你把一个分号放在错误的地方时,然后开始用花括号,括上任意行的代码,你在那里创建了一个局部范围,那个不是故意的行为。
And when I'm starting to write lots of lines of code, you know, it's frankly kind of useful to be able to see more on the screen at once without having to scroll.
当我开始写很多行代码的时候,你们懂的,这明显是有用的,当你可以在屏幕上看到更多的代码,而不用滚动屏幕。
So we've embedded some error checking, if you will, into our implementations.
所以我们植入了一些错误校验,如果你愿意,在我们的执行代码里。
And what we'll be doing is, early next week we'll be distributing code, which we'll ask you to study, about two or three pages of code, and then on the final we'll be asking you questions about the code.
我们现在要做的就是,在下周前半部分我们会发一些代码,给你们去研究,大概有两三页纸,然后在期末的时候,我们会问你一些有关代码的问题。
We've got the code for b search up there.
代码在这儿。
And what line of code am I on now?
那我现在在伪代码的哪一行呢?
And I suggest two things, right?
我在这儿的代码干了两件事情对不对?
And in the process of tidying it up and making it prettier, I'll often by accident find the bug.
让我的程序更漂亮些,在这个清理美化代码的过程中,我常常无意中发现我的错误。
Up on the screen, I've got-- I commented it out, but I've got a piece of code that you've seen before, right up here. OK?
我现在在大屏幕上标出来的,是你们以前看过的一段代码,就在这儿?
应用推荐