Does it really matter to you whether your code is going to take 300 years or 900 years to run?
或者900年区别大么?,这个数字的规模才是问题关键所在?
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.
但是我们这里要强调的是,当你写代码的时候,决定你的代码的效率的很重要的事情,就是你的设计决定。
The only thing that compiler needs to know is kind of what pattern to look for in the rest of your code.
编译器需要知道的唯一的东西是,用来在剩下的代码中寻找的函数形式。
In the code of conduct, professional conduct, that we embody by this code here is comparable to what you are expected to adhere to in your professional lives.
在行为准则中,专业准则,这个准则所体现的相当于,你所期待去追求的,在你的专业生活中。
The idea of a "code walkthrough" refers to the process of walking through your code verbally or visually with or without other people.
代码走查“的概念是单独或者和别人一起,通过查看或讨论学习你们的代码,的一个过程。
Thus far and in Scratch will pretty much focus on the idea of correctness: Does your code work as we asked it to and as you intended it to?
至此,人们大都是把注意力集中于正确性,观点上:你的代码是不是根据你的意愿,并按照你的要求来执行呢?
So what you typically do and a hash case is you design your code to deal with that.
你所需要做的就是通过设计你的代码,来解决上面的问题。
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.
如果你来自一个先前的背景,如果你们没有使用这个版本标志的话,在一个不同的系统中,你的代码可能运行地不太一样。
You need to, if you want something to be printed out inside your code, you need to tell the machine to do that.
你需要,如果你想要,在代码中显示一些东西的话,你需要告诉机器这么做。
People make really stupid decisions and so as you know in this course with P sets there are three axes that we look at when evaluating your code.
人们做了一个愚蠢的决定,在这个课程上,通过习题集,当执行你的代码的时候,有三个评估方面。
But in general, the choice of variable name is a great way of commenting your code.
但是通常来说,变量名称的选择,是评论你的代码的,一个重要方式。
I want to talk a little bit about how you use the things we've been building in terms of functions to help you structure and organize your code.
第一件事情就是我要谈下,怎么利用我们,所做的能在方法方面,帮助你们组织和优化代码。
So the interpreter is simply operating directly on your code at run time.
因此解释器在运行程序的时候,会直接的对你的代码进行操作。
But for the next week or two when you're writing programs, at least for the first time, generally if you're trying Scratch to debug them like you might have been trying to troubleshoot Scratch, you're probably going to reason - through it by looking through the your code -- -- top to bottom, maybe engage a staff member for help -- but your friend will also be printf.
但是,在接下来的一两周内,当你们写程序的时候,或至少在第一次写的时候,通常如果你在调试程序,就像你们可能已经试着调试过,你们或许是通过查看你们的代码,来推断你们的程序-,从头到尾,可能还需要别人的帮忙-,但是你的朋友也将要打印输出。
And if it sees S-W-A-P, open parentheses, close parentheses, and it hopefully sees two ints inside of it, that's all it needs to do in order to finish compiling your code.
如果它看到了SWAP,左圆括号,右圆括号,它可能载里面看到两个int数,那是它所需要做的,用来完成代码的编译。
So don't underestimate the value for the next week or two of just inserting printf statements into your code temporarily just to print out what the value of some variable is, or some expression is, so that you can just do a sanity check.
所以不要低估下一两周的重要性,虽然我们只将“printf“语句暂时地植入到,我们的代码中,只是用来打印一些,变量或表达式的值,所以你们提醒一下自己。
And then you can delete it once you're sure your code is working right.
当你们能够确定你们的代码运行正常的话,你们可以把这个“printf“,语句删除掉。
You don't have this particular code on your handout, you do have a code that uses the same concept.
在你们的讲义上没有这种代码,你可以看到相同概念的一个代码。
You need to be able to read that code and understand it as well as write your own.
你需要有能力,像编写,解读并理解那些代码。
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?
这有两点好处:,第一是可以帮助你发现程序中的,第二是把你的代码,在运行之前,转换为更有效率的指令的集合,对不对?
There is no substitute for reading your code.
没有什么能代替阅读代码。
At the end of the day, you can implement the exact same program using a while loop that you can using a for loop, it's just your code is going to look slightly different.
最终,你可以执行这个程序,再使用for循环的地方使用while循环,这只是使你的代码看起来稍微有点不同。
You can certainly hit Enter but as we saw-- seen that very quickly makes a mess of your code and such and so backslash N is new line.
你也可以敲回车键-,但是会让你的代码看起来乱七八糟,反斜杠n就是换行符。
So in other words, if you terminate these lines early, if you terminate the four loop early, if you terminate an if condition early with that semicolon, the code may very well work; and this is a common source -- of frustration and conundrum because you don't -- because your code looks right and yet it's misbehaving, but that semicolon means stop looking for subsequent lines of related code.
换句话说,如果你用分号过早的终止了这些代码行,如果你过早地终止了那个for循环,如果如此,一个if条件,代码可能可以运行,这就是,挫折和问题产生的源头,因为你没有-,因为你的代码看起来是正确的,但是运行是错误的,那个分号的意思是,停止寻找后面相关的代码。
Well I ought to be able to do that by simply generalizing the loop. And that's what the next piece of code on your a hand out shows you.
好的通过生成这个循环,我应该能够达到目的,这也是你们的讲义中下一段代码。
And we hope that at the end of the class, every time you're confronted with some technical problem, one of your first instincts is going to be, "How do I write the piece of code that's going to help me solve that?"
并且我们希望到了期末,每当你要面对一些,技术问题的时候,你们的本能之一将会是:,“我怎么才能编写一个代码,来帮我解决这问题?“
an interpreted language is often easier to debug, because you can still see your raw code there, but it's not always as fast.
解释语言调试起来很容易,因为你可以看到最原始的代码,但是这种语言不够快。
A huge one is, are you actually running the code you're looking at in your editor.
一个很大的错误就是你运行的程序,是否是你在编辑器中看到的程序。
You write the source code, the stuff that looks like this and then you save your file, and now you just have a text file.
比如你们写出像这样的源代码后,保存,你将会得到一个文本文件。
应用推荐