All right, you can see that this little piece of code, it's got a loop in there, and what's it doing?
好,你们看到的这一小块代码,是做了一个循环吧?,他在做什么?
Chapters 17 through 26 then are a block of material that's referred to as the "Holiness code" because of its special emphasis on holiness.
7章到26章是一块,被称为“神圣的代码“的内容“,因为它侧重于神圣。
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?
我现在在大屏幕上标出来的,是你们以前看过的一段代码,就在这儿?
So the open curly brace followed by the closed curly brace means everything inside of these curly braces should get executed, but only if that first condition is actually true.
所以左花括号后面跟着,右花括号,这意味着花括号里面所有的代码,都应该是要被执行的,但只有当第一个条件是正确的。
It could be, preconditions I want to have on input It could be, explanations of specific things you're doing.
也可以是我对输入的预期是什么,也可以是,对代码,正在进行的特定操作的解释。
What is that? It's the piece of code we wrote for computing square roots, square roots of actually perfect squares.
对吧?这是什么呢?,这是我们写的计算平方根的代码,计算完全全平方根的。
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 the things we were trying to stress were that it's an important design decision when you are coming up with a piece of code, as to what kind of efficiency your code has.
但是我们这里要强调的是,当你写代码的时候,决定你的代码的效率的很重要的事情,就是你的设计决定。
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.
现在就提供给你们一些框架,在代码中有些空白,是为了让你们了解其中的思想,如果是你自己,若时间允许,那就尽量写大的程序。
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.
代码就在这儿,它的作用是当我运行到不同地方时,就输出我所在方位的信息,我想让你们看的就是注意这儿发生了什么,好了我调用了一个。
The only thing that compiler needs to know is kind of what pattern to look for in the rest of your code.
编译器需要知道的唯一的东西是,用来在剩下的代码中寻找的函数形式。
So things break if you try-- if the computer tries to take you too literally so it would not be correct generally to do something like that.
如果你把它分开-,那么电脑会逐字逐句地解析,你拆开写的代码,由此得到的结果一般都是错误的。
And I want to remind you, that block of code is a set of instructions, the same set of instructions that are going to be done each time through the loop.
我想提醒大家,这块代码是一个指令集,一个每次循环都会被执行的相同指令集,会变化的仅仅是变量的值。
OK. So. Why did I do it? It's a simple example, I agree, but notice what I just did. It allowed me to highlight, is the code doing the right thing?
这是一个简单的例子,我同意,但是请注意我刚才是怎么做的,我通过它想要强调,代码是做了正确的?
So a couple of commands and then an interesting code and then the teaser, that's a teaser.
总结起来,就是几个命令,一个有意思的代码,然后是那个小技巧,那是一个小技巧。
Second thing to notice, is that little piece of pseudo code is telling me things about values.
然后需要注意的是,这些伪代码告诉了一些关于值方面的事情,我需要一个浮点数。
But now at least we're a step closer to doing something that's a little bit more compelling, but this isn't always a good thing.
但是现在至少是,向更引人入胜的代码靠近了一步,但这并不总是好事。
That code says the following: the IF says, I've got an expression, I'm going to evaluate it.
代码的含义是这样的:,我有一个表达式,我会去对这个表达式求值。
It's words to you, or to the reader of the code, that are telling you what's going on inside of this code. OK?
注释是一些对你,或者对代码阅读者说的一些话,告诉你这段代码,是干什么的,对不对?
This chunk of code and this chunk of code, they're really doing the same thing.
这一块代码和这一块代码,它们实际上是相同的功能。
This little set of code here from create insert and number. What's create do?
这一小段代码是创建插入和编号的,创建是做什么的?
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.
这样我们就从苹果的约束下解放出来,这些代码是在网站上流通的,使用它们可能损坏你们的。
So, I'm getting a string and so what really am I doing in this line of code?
那么,我得到一个字符串,这行代码实际上是干什么的呢?
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.
因为在考试中,是没有时间去第一次看代码,并弄懂它的意思的。
But in general, the choice of variable name is a great way of commenting your code.
但是通常来说,变量名称的选择,是评论你的代码的,一个重要方式。
Those are fancy terms. Decomposition is a way of putting structure onto the code.
这些都是诱人的术语,分解是一种将代码结构化的方法。
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?
这有两点好处:,第一是可以帮助你发现程序中的,第二是把你的代码,在运行之前,转换为更有效率的指令的集合,对不对?
copy1 So this is the code that we had a moment ago for copy one.
这是我们之前的那个代码。
I'm going to use my own special program that will color code things for me in class, but the idea is the same; it's a text editor.
我将用我自己专门的程序,那个会分类为我标出代码的颜色,但是那个思想是一样的,这是一个文本编辑器。
You want to write the specs so that everybody does in fact know what this piece of code is doing, and you're writing it each time around.
但是你得养成良好的习惯和编程风格,你得撰写规范说明从而保证,每个人都知道这段代码是干什么的。
应用推荐