毕业设计外文资料翻译-Thinking in Java 4th Edition_第1页
毕业设计外文资料翻译-Thinking in Java 4th Edition_第2页
毕业设计外文资料翻译-Thinking in Java 4th Edition_第3页
毕业设计外文资料翻译-Thinking in Java 4th Edition_第4页
毕业设计外文资料翻译-Thinking in Java 4th Edition_第5页
已阅读5页,还剩10页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、毕业设计外文资料翻译学 院: 专业班级: 学生姓名: 学 号: 指导教师: 外文出处: Thinking in Java 4th Edition 附 件:1.外文资料翻译译文; 2.外文原文 指导教师评语:该英文文献是介绍Java对象基本概念的资料,与毕业设计所用的技术相关度高。从该生翻译的内容来看,术语翻译准确度比较高,体现了较强的英语应用水平。翻译工作认真细致,严格按照规定,翻译材料能与原文能保持一致,能正确表达出原文意思。签名: 年 月 日外文资料翻译译文Thinking in Java 4th Edition对象入门 “我们自然地减少并将它组织成概念,并赋予意义,很大程度上是因为在我们

2、的语言模式下各方达成一种协议除了通过订阅的组织和分类数据协议的法令,否则我们不能交流。”本杰明李沃尔夫(1897 - 1941)计算机革命的起源是一台机器。因此我们的编程语言的起源往往也是这样的机器。但电脑并不全是机器思维放大工具(史蒂夫乔布斯喜欢说成“头脑的自行车”)和不同的表达媒介。结果,工具开始看起来不那么像机器,更像我们的思想,也像 其他形式的表达,如写作、绘画、雕塑、动画和电影制作。面向对象编程(OOP)是一部分用计算机作为表达媒介的活动。本章将介绍OOP的基本概念,包括开发方法的概述。这一章乃至这本书,假设你有编程经验,尽管不一定在C。如果你觉得你需要在开始阅读这本书之前要在编程上

3、有更多的准备,你应该先看看在C多媒体研讨会中思考,它能从www.MindV下载。这一章是背景和补充材料。许多人在不了解大局的情况下涉水面向对象编程不会觉得太容易。因此,这里有许多概念来给你介绍一个完备的OOP的概述。然而,其他人可能不会理解全局概念直到先给他们看的一些结构,这些人可能会变得停滞不前并且失去了一些代码来让他们上手。如果你是后者的一部分并渴望得到具体的语言,随意跳过这章节-跳过它不会阻止你写程序或学习语言。然而,你将最终要回到这里来填满你的知识这样就你就能理解为什么对象很重要并且如何来设计它们。1.1 抽象的进步 所有编程语言的最终目的都是提供一种“抽象”方法。一种较有争议的说法是

4、:解决问题的复杂程度直接取 决于抽象的种类及质量。这儿的“种类”是指准备对什么进行“抽象”?汇编语言是对基础机器的少量抽 象。后来的许多“命令式”语言(如FORTRAN,BASIC 和 C)是对汇编语言的一种抽象。与汇编语言相比,这 些语言已有了长足的进步,但它们的抽象原理依然要求我们着重考虑计算机的结构,而非考虑问题本身的结 构。在机器模型(位于“方案空间”)与实际解决的问题模型(位于“问题空间”)之间,程序员必须建立起一种联系。这个过程要求人们付出较大的精力,而且由于它脱离了编程语言本身的范围,造成程序代码很 难编写,而且要花较大的代价进行维护。由此造成的副作用便是一门完善的“编程方法”学

5、科。 为机器建模的另一个方法是为要解决的问题制作模型。对一些早期语言来说,如 LISP 和 APL,它们的做法是 “从不同的角度观察世界”“所有问题都归纳为列表”或“所有问题都归纳为算法”。PROLOG则将所有 问题都归纳为决策链。对于这些语言,我们认为它们一部分是面向基于“强制”的编程,另一部分则是专为 处理图形符号设计的。每种方法都有自己特殊的用途,适合解决某一类的问题。但只要超出了它们力所能及的范围,就会显得非常笨拙。 面向对象的程序设计在此基础上则跨出了一大步,程序员可利用一些工具表达问题空间内的元素。由于这种表达非常普遍,所以不必受限于特定类型的问题。我们将问题空间中的元素以及它们在

6、方案空间的表示物称 作“对象”(Object)。当然,还有一些在问题空间没有对应体的其他对象。通过添加新的对象类型,程序可进行灵活的调整,以便与特定的问题配合。所以在阅读方案的描述代码时,会读到对问题进行表达的话语。与我们以前见过的相比,这无疑是一种更加灵活、更加强大的语言抽象方法。总之,OOP允许我们根据问题来描述问题,而不是根据方案。然而,仍有一个联系途径回到计算机。每个对象都类似一台小计算机; 它们有自己的状态,而且可要求它们进行特定的操作。与现实世界的“对象”或者“物体”相比,编程“对象”与它们也存在共通的地方:它们都有自己的特征和行为。 Alan Kay 总结了 Smalltalk

7、的五大基本特征。这是第一种成功的面向对象程序设计语言,也是Java 的基础 语言。通过这些特征,我们可理解“纯粹”的面向对象程序设计方法是什么样的: (1)所有东西都是对象。可将对象想象成一种新型变量;它保存着数据,但可要求它对自身进行操作。理论 上讲,可从要解决的问题身上提出所有概念性的组件,然后在程序中将其表达为一个对象。 (2) 程序是一大堆对象的组合;通过消息传递,各对象知道自己该做些什么。为了向对象发出请求,需向那个对象“发送一条消息”。更具体地讲,可将消息想象为一个调用请求,它调用的是从属于目标对象的一个 子例程或函数。(3) 每个对象都有自己的存储空间,可容纳其他对象。或者说,通

8、过封装现有对象,可制作出新型对象。所 以,尽管对象的概念非常简单,但在程序中却可达到任意高的复杂程度。 (4) 每个对象都有一种类型。根据语法,每个对象都是某个“类”的一个“实例”。其中,“类”(Class) 是“类型”(Type)的同义词。一个类最重要的特征就是“能将什么消息发给它?”。 (5) 同一类所有对象都能接收相同的消息。这实际是别有含义的一种说法,大家不久便能理解。由于类型为 “圆”(Circle)的一个对象也属于类型为“形状”(Shape)的一个对象,所以一个圆完全能接收形状消 息。这意味着可让程序代码统一指挥“形状”,令其自动控制所有符合“形状”描述的对象,其中自然包括 “圆”

9、。这一特性称为对象的“可替换性”,是OOP最重要的概念之一。 一些语言设计者认为面向对象的程序设计本身并不足以方便解决所有形式的程序问题,提倡将不同的方法组 合成“多形程序设计语言”。 对象具有状态,行为和身份。这意味着一个对象可以有内部数据(给它状态)、方法(生产行为),和每个对象可以独特区别于其他对象把这放个在一个具体的容器中,在内存每个对象都有一个唯一的地址。 1.2 对象的接口 亚里士多德或许是认真研究“类型”概念的第一人,他曾谈及“鱼类和鸟类”的问题。在世界首例面向对象 语言Simula-67 中,第一次用到了这样的一个概念: 所有对象尽管各有特色都属于某一系列对象的一部分,这些对象

10、具有通用的特征和行为。在 Simula-67 中,首次用到了class 这个关键字,它为程序引入了一个全新的类型。(clas 和 type 通常可互换使 用;注释)。 :有些人进行了进一步的区分,他们强调“类型”决定了接口,而“类”是那个接口的一种特殊实现方式。Simula是一个很好的例子。正如这个名字所暗示的,它的作用是“模拟”(Simulate)象“银行出纳员”这 样的经典问题。在这个例子里,我们有一系列出纳员、客户、帐号以及交易等。每类成员(元素)都具有一 些通用的特征:每个帐号都有一定的余额;每名出纳都能接收客户的存款;等等。与此同时,每个成员都有 自己的状态;每个帐号都有不同的余额;

11、每名出纳都有一个名字。所以在计算机程序中,能用独一无二的实 体分别表示出纳员、客户、帐号以及交易。这个实体便是“对象”,而且每个对象都隶属一个特定的 “类”,那个类具有自己的通用特征与行为。 因此,在面向对象的程序设计中,尽管我们真正要做的是新建各种各样的数据“类型”(Type),但几乎所有面向对象的程序设计语言都采用了“class”关键字。当您看到“type”这个字的时候,请同时想到 “class”;反之亦然。 由于一个类描述了一组具有相同特征的对象(数据元素)和行为(功能),因为一个浮点数,一个类可是一个数据类型,举个例子,它也有一系列的特征和行为。所不同的是, 一个程序员定义一个类来适应

12、一个问题而不是被迫使用现有的用来代表一个单位的存储在一台机器的数据类型。你通过添加新的数据类型扩展编程语言达到你的特定需要。编程系统欢迎新类并且给他们所有的照顾和类型检查这样可以给内置类型。面向对象的方法并不局限于创建模拟。无论你是否同意任何程序是一个模拟的系统设计、使用OOP技术可以很容易地大量的问题减少成一个简单的解决方案。建好一个类后,可根据情况生成许多对象。随后,可将那些对象作为要解决问题中存在的元素进行处理。事实上,当我们进行面向对象的程序设计时,面临的最大一项挑战性就是:如何在“问题空间”(问题实际存 在的地方)的元素与“方案空间”(对实际问题进行建模的地方,如计算机)的元素之间建

13、立理想的“一对一”对应或映射关系。 如何利用对象完成真正有用的工作呢?必须有一种办法能向对象发出请求,令其做一些实际的事情,比如完 成一次交易、在屏幕上画一些东西或者打开一个开关等等。每个对象仅能接受特定的请求。我们向对象发出 的请求是通过它的“接口”(Interface)定义的,对象的“类型”或“类”则规定了它的接口形式。“类型”与“接口”的等价或对应关系是面向对象程序设计的基础。 下面让我们以电灯泡为例: 接口确定您可以针对特定对象的请求。然而,必须在有代码的地方才可以满足这一要求。这包括实施与隐藏的数据。从程序设计的角度来看,这并不复杂。类型有一个与每个可能的请求相关联的方法,当您对某个

14、对象做了一个特定的请求时,该方法被调用。这个过程通常是通过说你“发送消息”(向一个对象发送一个请求)来概括,并且该对象将处理该消息(它执行的代码)。在这个例子中,类型类的名称是 Light,可向 Light 对象发出的请求包括包括打开(on)、关闭(off)、 变得更明亮(brighten)或者变得更暗淡(dim)。通过简单地声明一个名字(lt),我们为 Light 对象创建 了一个“句柄”。然后用new关键字新建类型为 Light 的一个对象。再用等号将其赋给句柄。为了向对象发 送一条消息,我们列出句柄名(lt),再用一个句点符号(.)把它同消息名称(on)连接起来。从中可以看出,使用一些预

15、先定义好的类时,我们在程序里采用的代码是非常简单和直观的。 前面的图是统一建模语言(UML)的格式。每一个类代表一个盒子而且在盒子的类型名称在顶部,任何你关心的数据成员会在中间部分的描述,并且方法(属于这个对象的功能,收到任何消息,你发送到该对象)在底部的部分。通常,只有类的公共方法的名称是UML设计图所显示的,所以中间的部分是不显示的,在这种情况下。如果你只对类名称感兴趣,那么下面的部分就不需要显示了。 HYPERLINK /?aldtype=85&keyfrom=alading l # 1.3对象提供服务当你试图开发或理解一个程序设计时,最好的方法之一是把对象当作“服务提供者”,你的程序本

16、身将为用户提供服务,并且它将使用其他对象提供的服务来实现这个目标。你可以看Introduction to Objects 19 中提及的(甚至更好地定位在现有的代码库)一组对象解决问题提供最佳服务。开始做这件事的一个方法是问,“如果我能神奇地把他们从一顶帽子里拉出来,什么东西会马上解决我的问题?例如,假设你正在创建一个记账程序。你可能会想到一些对象包含预先定义的记账式输入屏幕,另一组的对象执行的记账计算,并且还有一个对象处理印刷的检查和发票的所有不同类型的打印机。也许有些对象已经存在,对于那些不喜欢的对象,他们会是什么样子?这些对象提供什么服务,他们需要什么样的目标来完成他们的义务?如果你继续

17、这样做,你最终会达到一个点,你可以说,“这个对象似乎很简单,坐下来写”或“我确信,对象必须存在”这是一个合理的方式来分解成一组问题的对象。思想的对象作为服务供应商有一个额外的好处:它有助于提高对象的凝聚力。高内聚性是软件设计的一个基本品质:它意味着软件组件的各个方面(例如一个对象,虽然这也适用于一个方法或一个对象库)“适合”。一个问题就是在设计对象时就已经把太多的功能放到一个对象。例如,在您的支票打印模块,您可以决定您需要一个对象,知道所有的格式化和打印。你可能会发现,这对于一个对象来说太多了,你需要的是三个或更多的对象。一个对象可以是一个所有检查布局的目录,它可以查询有关如何打印检查的信息。

18、一个对象或一组对象可以是一个通用的打印接口,知道所有的不同类型的打印机(但没有什么关于记帐这一个是购买而不是写自己的候选人)。三个对象之中的任何一个对象可以使用其他的服务来完成任务。因此,每一个对象都有一个集合的服务提供。在一个良好的面向对象的设计中,每一个对象做一件事,但不会试图做太多。这不仅允许现有的对象可以能够购买(打印机接口对象),但它也产生新的对象,可能会再利用其他地方(检查布局的目录)。把对象作为服务提供者是一个很好的简化工具。这不仅是在设计过程中游泳,而且在当别人试图理解你的代码或重用一个对象时也有用。如果他们能看到这个对象的价值,根据它提供的服务,它可以更容易地把它自己融入到设

19、计中去。 HYPERLINK /?aldtype=85&keyfrom=alading l # 1.4 HYPERLINK /?aldtype=85&keyfrom=alading l # o 清空 隐藏的实现 为方便后面的讨论,让我们先对这一领域的从业人员作一下分类。从根本上说,大致有两方面的人员涉足面向对象的编程:“类创建者”(创建新数据类型的人)以及“客户程序员”(在自己的应用程序中采用现成数据类型的人)。 对客户程序员来讲,最主要的目标就是收集一个充斥着各种类的编程“工具箱”,以便快速开发符合自己要求的应用。而对类创建者来说,他们的目标则是从头构建一个类,只向客户程序员开放有必要开放的

20、东西(接口),其他所有细节都隐藏起来。为什么要这样做?隐藏之后,客户程序员就不能接触和改变那些细节,所以原创者不用担心自己的作品会受到非法修改,可确保它们不会对其他人造成影响。“接口”( Interface)规定了可对一个特定的对象发出哪些请求。然而,必须在某个地方存在着一些代码,以便满足这些请求。这些代码与那些隐藏起来的数据便叫作“隐藏的实现”。站在程式化程序编写( Procedural Programming )的角度,整个问题并不显得复杂。一种类型含有与每种可能的请求关联起来的函数。一旦向对象发出一个特定的请求,就会调用那个函数。我们通常将这个过程总结为向对象“发送一条消息”(提出一个请

21、求)。对象的职责就是决定如何对这条消息作出反应(执行相应的代码)。对于任何关系,重要一点是让牵连到的所有成员都遵守相同的规则。创建一个库时,相当于同客户程序员建立了一种关系。 对方也是程序员,但他们的目标是组合出一个特定的应用(程序),或者用您的库构建一个更大的库。若任何人都能使用一个类的所有成员,那么客户程序员可对那个类做任何事情,没有办法强制他们遵守任何约束。即便非常不愿客户程序员直接操作类内包含的一些成员,但倘若未进行访问控制,就没有办法阻止这一情况的发生 所有东西都会暴露无遗。有两方面的原因促使我们控制对成员的访问。第一个原因是防止程序员接触他们不该接触的东西 通常是内部数据类型的设计

22、思想。若只是为了解决特定的问题,用户只需操作接口即可,毋需明白这些信息。我们向用户提供的实际是一种服务,因为他们很容易就可看出哪些对自己非常重要,以及哪些可忽略不计。进行访问控制的第二个原因是允许库设计人员修改内部结构,不用担心它会对客户程序员造成什么影响。例如,我们最开始可能设计了一个形式简单的类,以便简化开发。以后又决定进行改写,使其更快地运行。若接口与实现方法早已隔离开,并分别受到保护,就可放心做到这一点,只要求用户重新链接一下即可。Java 采用三个显式(明确)关键字以及一个隐式(暗示)关键字来设置类边界: public,private,protected 以及暗示性的 friendl

23、y。若未明确指定其他关键字,则默认为后者。这些关键字的使用和含义都是相当直观的,它们决定了谁能使用后续的定义内容。“public”(公共)意味着后续的定义任何人均可使用。而在另一方面,“private”(私有)意味着除您自己、类型的创建者以及那个类型的内部函数成员,其他任何人都不能访问后续的定义信息。 private 在您与客户程序员之间竖起了一堵墙。若有人试图访问私有成员,就会得到一个编译期错误。“friendly ”(友好的)涉及“包装”或“封装”(Package)的概念即 Java 用来构建库的方法。若某样东西是“友好的”,意味着它只能在这个包装的范围内使用(所以这一访问级别有时也叫作“

24、包装访问”)。“ protected”(受保护的)与“ private”相似,只是一个继承的类可访问受保护的成员,但不能访问私有成员。继承的问题不久就要谈到。2.外文原文Introduction to Objects“We cut nature up, organize it into concepts, and ascribe significances as we do, largely because we are parties to an agreement that holds throughout our speech community and is codified in t

25、he patterns of our language we cannot talk at all except by subscribing to the organization and classification of data which the agreement decrees.”Benjamin Lee Whorf (1897-1941)The genesis of the computer revolution was in a machine. The genesis of our programming languages thus tends to look like

26、that machine. But computers are not so much machines as they are mind amplification tools (“bicycles for the mind,” as Steve Jobs is fond of saying) and a different kind of expressive medium. As a result, the tools are beginning to look less like machines and more like parts of our minds, and also l

27、ike other forms of expression such as writing, painting, sculpture, animation, and filmmaking. Object-oriented programming (OOP) is part of this movement toward using the computer as an expressive medium.This chapter will introduce you to the basic concepts of OOP, including an overview of developme

28、nt methods. This chapter, and this book, assumes that you have someprogramming experience, although not necessarily in C. If you think you need morepreparation in programming before tackling this book, you should work through theThinking in C multimedia seminar, downloadable from HYPERLINK http:/www

29、.MindV. www.MindV.This chapter is background and supplementary material. Many people do not feel comfortable wading into object-oriented programming without understanding the big picture first. Thus, there are many concepts that are introduced here to give you a solid overview of OOP. However, other

30、 people may not get the big picture concepts until theyve seen some of the mechanics first; these people may become bogged down and lost without some code to get their hands on. If youre part of this latter group and are eager to get to the specifics of the language, feel free to jump past this chap

31、terskipping it at this point will not prevent you from writing programs or learning the language. However, you will want to come back here eventually to fill in your knowledge so you can understand why objects are important and how to design with them.The progress of abstractionAll programming langu

32、ages provide abstractions. It can be argued that the complexity of the problems youre able to solve is directly related to the kind and quality of abstraction. By “kind” I mean, “What is it that you are abstracting?” Assembly language is a small abstraction of the underlying machine. Many so-called

33、“imperative” languages that followed (such as FORTRAN, BASIC, and C) were abstractions of assembly language. These languages are big improvements over assembly language, but their primary abstraction still requires you to think in terms of the structure of the computer rather than the structure of t

34、he problem you are trying to solve. The programmer must establish the association between the machinemodel (in the “solution space,” which is the place where youre implementing that solution, such as a computer) and the model of the problem that is actually being solved (in the 16 Thinking in Java B

35、ruce Eckel “problem space,” which is the place where the problem exists, such as a business). The effort required to perform this mapping, and the fact that it is extrinsic to the programming language, produces programs that are difficult to write and expensive to maintain, and as a side effect crea

36、ted the entire “programming methods” industry.The alternative to modeling the machine is to model the problem youre trying to solve. Early languages such as LISP and APL chose particular views of the world (“All problems are ultimately lists” or “All problems are algorithmic,” respectively). Prolog

37、casts all problems into chains of decisions. Languages have been created for constraint-based programming and for programming exclusively by manipulating graphical symbols. (The latter proved to be too restrictive.) Each of these approaches may be a good solution to the particular class of problem t

38、heyre designed to solve, but when you step outside of that domain they become awkward.The object-oriented approach goes a step further by providing tools for the programmer to represent elements in the problem space. This representation is general enough that the programmer is not constrained to any

39、 particular type of problem. We refer to the elements in the problem space and their representations in the solution space as “objects.” (You will also need other objects that dont have problem-space analogs.) The idea is that the program is allowed to adapt itself to the lingo of the problem by add

40、ing new types of objects, so when you read the code describing the solution, youre reading words that also express the problem. This is a more flexible and powerful language abstraction than what weve had before.1 Thus, OOP allows you to describe the problem in terms of the problem, rather than in t

41、erms of the computer where the solution will run. Theres still a connection back to the computer: Each object looks quite a bit like a little computerit has a state, and it hasoperations that you can ask it to perform. However, this doesnt seem like such a bad analogy to objects in the real worldthe

42、y all have characteristics and behaviors.Alan Kay summarized five basic characteristics of Smalltalk, the first successful objectoriented language and one of the languages upon which Java is based. These characteristics represent a pure approach to object-oriented programming:1. Everything is an obj

43、ect. Think of an object as a fancy variable; it stores data, but you can “make requests” to that object, asking it to perform operations on itself. In theory, you can take any conceptual component in the problem youre trying to solve (dogs, buildings, services, etc.) and represent it as an object in

44、 your program.2. A program is a bunch of objects telling each other what to do by sending messages. To make a request of an object, you “send a message” to that object. More concretely, you can think of a message as a request to call a method that belongs to a particular object.3. Each object has it

45、s own memory made up of other objects. Put another way, you create a new kind of object by making a package containing existing objects. Thus, you can build complexity into a program while hiding it behind the simplicity of objects.4. Every object has a type. Using the parlance, each object is an in

46、stance of a class, in which “class” is synonymous with “type.” The most important distinguishing characteristic of a class is “What messages can you send to it?”5. All objects of a particular type can receive the same messages. This is actually a loaded statement, as you will see later. Because an o

47、bject of type “circle” is also an object of type “shape,” a circle is guaranteed to accept shape messages. This means you can write code that talks to shapes and automatically handle anything thatfits the description of a shape. This substitutability is one of the powerful concepts in OOP.Booch offe

48、rs an even more succinct description of an object:An object has state, behavior and identity.This means that an object can have internal data (which gives it state), methods (to produce behavior), and each object can be uniquely distinguished from every other objectto put this in a concrete sense, e

49、ach object has a unique address in memory.2An object has an interfaceAristotle was probably the first to begin a careful study of the concept of type; he spoke of “the class of fishes and the class of birds.” The idea that all objects, while being unique, are also part of a class of objects that hav

50、e characteristics and behaviors in common was used directly in the first object-oriented language, Simula-67, with its fundamental keyword class that introduces a new type into a program.Simula, as its name implies, was created for developing simulations such as the classic “bank teller problem.” In

51、 this, you have numerous tellers, customers, accounts, transactions, and units of moneya lot of “objects.” Objects that are identical except for their state during a programs execution are grouped together into “classes of objects,” and thats where the keyword class came from. Creating abstract data

52、 types (classes) is a fundamental concept in object-oriented programming. Abstract data types work almost exactly like built-in types: You can create variables of a type (called objects or instances in object-oriented parlance) and manipulate those variables (called sending messages or requests; you

53、 send a message and the object figures out what to do with it). The members (elements) of each class share some commonality: Every account has a balance, every teller can accept a deposit, etc. At the same time, each member has its own state: Each account has a different balance, each teller has a n

54、ame. Thus, the tellers, customers, accounts, transactions, etc., can each be represented with a unique entity in the computer program. This entity is the object, and each object belongs to a particular class that defines its characteristics and behaviors.So, although what we really do in object-orie

55、nted programming is create new data types, virtually all object-oriented programming languages use the “class” keyword. When you see the word “type” think “class” and vice versa.3Since a class describes a set of objects that have identical characteristics (data elements) and behaviors (functionality

56、), a class is really a data type because a floating point number, for example, also has a set of characteristics and behaviors. The difference is that a programmer defines a class to fit a problem rather than being forced to use an existing data type that was designed to represent a unit of storage

57、in a machine. You extend the programming language by adding new data types specific to your needs. The programming system welcomes the new classes and gives them all the care and type checking that it gives to built-in types.The object-oriented approach is not limited to building simulations. Whethe

58、r or not you agree that any program is a simulation of the system youre designing, the use of OOP techniques can easily reduce a large set of problems to a simple solution.Once a class is established, you can make as many objects of that class as you like, and then manipulate those objects as if the

59、y are the elements that exist in the problem you are trying to solve. Indeed, one of the challenges of object-oriented programming is to create a one-toone mapping between the elements in the problem space and objects in the solution space. But how do you get an object to do useful work for you? The

60、re needs to be a way to make a request of the object so that it will do something, such as complete a transaction, draw something on the screen, or turn on a switch. And each object can satisfy only certain requests. The requests you can make of an object are defined by its interface, and the type i

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论