And that's exactly one of the reasons why I want to have the functions, because I've separated those out.
这就是创建方法的原因,只是因为我把,实现和使用分离了。
and push your ideas forward along with you.
和你一起,把你的想法实现。
And I would be able to simply bury away the details of how those other instances are created from how I want to use them by simply calling methods on the classes.
也就是一些线段的组合,我还可以把怎么实现那些,实例的细节包装起来,把它和调用实例分开来,我们下次还会接着讲这个。
Because what you don't see in this file is any code a that actually says put a letter of the alphabet at the top left hand corner of the screen and then put the next character to the right in other words, I'm taking for granted at this moment in time that my computer knows how to print something to the screen.
就是这些你在本文件中看不到的一些代码,实现了将首字母,放在屏幕的左上角,然后把其他字母加在其右边,我想当然地认为,我的电脑知道如何打印相应信息到屏幕上。
Oftentimes, inventions that seem, in the abstract, to be good ideas may be impossible because something that you have to do to make it actually come into practice is too expensive and so it's not economic to produce the invention.
通常在理论上,创新固然不错,但却很难实现,因为把创意变成现实,花费会相当的昂贵,实现这样的创意非常不合算
So, if you like, I've built a separation between the user and the implementer.
好,也就是说这样做,把用户和实现者分离了。
All right. What does this have to do with my divisor example? This says I can make tuples, but imagine now going back to my divisor example and I want to gather up the elements as I go along. I ought to be able to do that by in fact just adding the pieces in.
这意味着我可以创建元组了,但是想像下回到我们的除数的例子,在处理过程中我们想把目标数的除数,收集起来,我应该能够通过把这些数,一个一个加进来来实现这个目的,我正是要去这么做,也就是。
What we're really getting at is the idea of saying I want to have a way of grouping together information into units that make sense. So I can go back to one of those topics we had at the beginning, which is the idea of abstraction, that I can create one of those units as a simple entity, bury away the details and write really modular code.
组合成为有意义的单元,那么这就让我们回到,一开始讲的话题之一了,这就是抽象的概念,也就是我可以以一个简单的,实体的形式创建这样的一个单元,把具体实现隐藏然后写一些,真正模块化的代码,我们在以后的课程中。
OK, so how can I code this up? Well, you might think, let's just jump in and write some code, I don't want to quite do that though, because I want to show you another tool that's valuable for thinking about how to structure the code, and that is a something called a flow chart. Now.
好,那么我怎么把这个以代码实现呢,你可能会想,让我们进去直接写代码把,但是我不想这么做,因为我想教给大家另外一项很有价值的,用来组织代码的工具,叫做流程图,现在,像Guttag教授,和我这么大岁数的人。
And yeah, I know it comes built in, that's OK, what we want to do is use it as an example to look at it.
对,我知道这个方法可以通过内置的算法,来实现,这没关系,我们只是,把它当做一个例子来讲解。
应用推荐