ImageVerifierCode 换一换
格式:DOCX , 页数:10 ,大小:123.26KB ,
资源ID:4388569      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/4388569.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(ZYBS网上书店英文文献.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

ZYBS网上书店英文文献.docx

1、ZYBS网上书店英文文献ZYBS网上书店英文文献What Is an Object? Objects are key to understanding object-oriented technology. You can look around you now and see many examples of real-world objects: your dog, your desk, your television set, your bicycle. Real-world objects share two characteristics: They all have state a

2、nd behavior. For example, dogs have state (name, color, breed, hungry) and behavior (barking, fetching, wagging tail). Bicycles have state (current gear, current pedal cadence, two wheels, number of gears) and behavior (braking, accelerating, slowing down, changing gears). Software objects are model

3、ed after real-world objects in that they too have state and behavior. A software object maintains its state in one or more variables. A variable is an item of data named by an identifier. A software object implements its behavior with methods. A method is a function (subroutine) associated with an o

4、bject. Definition: An object is a software bundle of variables and related methods. You can represent real-world objects by using software objects. You might want to represent real-world dogs as software objects in an animation program or a real-world bicycle as a software object in the program that

5、 controls an electronic exercise bike. You can also use software objects to model abstract concepts. For example, an event is a common object used in window systems to represent the action of a user pressing a mouse button or a key on the keyboard. The following illustration is a common visual repre

6、sentation of a software object. A software object. Everything the software object knows (state) and can do (behavior) is expressed by the variables and the methods within that object. A software object that models your real-world bicycle would have variables that indicate the bicycles current state:

7、 Its speed is 18 mph, its pedal cadence is 90 rpm, and its current gear is 5th. These variables are formally known as instance variables because they contain the state for a particular bicycle object; in object-oriented terminology, a particular object is called an instance. The following figure ill

8、ustrates a bicycle modeled as a software object. A bicycle modeled as a software object. In addition to its variables, the software bicycle would also have methods to brake, change the pedal cadence, and change gears. (It would not have a method for changing its speed because the bikes speed is just

9、 a side effect of which gear its in and how fast the rider is pedaling.) These methods are known formally as instance methods because they inspect or change the state of a particular bicycle instance. Object diagrams show that an objects variables make up the center, or nucleus, of the object. Metho

10、ds surround and hide the objects nucleus from other objects in the program. Packaging an objects variables within the protective custody of its methods is called encapsulation. This conceptual picture of an object a nucleus of variables packaged within a protective membrane of methods is an ideal re

11、presentation of an object and is the ideal that designers of object-oriented systems strive for. However, its not the whole story. Often, for practical reasons, an object may expose some of its variables or hide some of its methods. In the Java programming language, an object can specify one of four

12、 access levels for each of its variables and methods. The access level determines which other objects and classes can access that variable or method. Refer to the Controlling Access to Members of a Class section for details. Encapsulating related variables and methods into a neat software bundle is

13、a simple yet powerful idea that provides two primary benefits to software developers: Modularity: The source code for an object can be written and maintained independently of the source code for other objects. Also, an object can be easily passed around in the system. You can give your bicycle to so

14、meone else, and it will still work. Information-hiding: An object has a public interface that other objects can use to communicate with it. The object can maintain private information and methods that can be changed at any time without affecting other objects that depend on it. You dont need to unde

15、rstand a bikes gear mechanism to use it. What Is a Message? A single object alone generally is not very useful. Instead, an object usually appears as a component of a larger program or application that contains many other objects. Through the interaction of these objects, programmers achieve higher-

16、order functionality and more complex behavior. Your bicycle hanging from a hook in the garage is just a bunch of metal and rubber; by itself, it is incapable of any activity; the bicycle is useful only when another object (you) interacts with it (by pedaling). Software objects interact and communica

17、te with each other by sending messages to each other. When object A wants object B to perform one of Bs methods, object A sends a message to object B (see the following figure). Objects interact by sending each other messages. Sometimes, the receiving object needs more information so that it knows e

18、xactly what to do; for example, when you want to change gears on your bicycle, you have to indicate which gear you want. This information is passed along with the message as parameters. Messages use parameters to pass along extra information that the object needs in this case, which gear the bicycle

19、 should be in. These three parts are enough information for the receiving object to perform the desired method. No other information or context is required. Messages provide two important benefits: An objects behavior is expressed through its methods, so (aside from direct variable access) message p

20、assing supports all possible interactions between objects. Objects dont need to be in the same process or even on the same machine to send messages back and forth and receive messages from each other. What Is a Class? In the real world, you often have many objects of the same kind. For example, your

21、 bicycle is just one of many bicycles in the world. Using object-oriented terminology, we say that your bicycle object is an instanceof the class of objects known as bicycles. Bicycles have some state (current gear, current cadence, two wheels) and behavior (change gears, brake) in common. However,

22、each bicycles state is independent of and can be different from that of other bicycles. When building them, manufacturers take advantage of the fact that bicycles share characteristics, building many bicycles from the same blueprint. It would be very inefficient to produce a new blueprint for every

23、bicycle manufactured. In object-oriented software, its also possible to have many objects of the same kind that share characteristics: rectangles, employee records, video clips, and so on. Like bicycle manufacturers, you can take advantage of the fact that objects of the same kind are similar and yo

24、u can create a blueprint for those objects. A software blueprint for objects is called a class (see the following figure). A visual representation of a class. Definition: A class is a blueprint that defines the variables and the methods common to all objects of a certain kind. The class for our bicy

25、cle example would declare the instance variables necessary to contain the current gear, the current cadence, and so on for each bicycle object. The class would also declare and provide implementations for the instance methods that allow the rider to change gears, brake, and change the pedaling caden

26、ce, as shown in the next figure. The bicycle class. After youve created the bicycle class, you can create any number of bicycle objects from that class. When you create an instance of a class, the system allocates enough memory for the object and all its instance variables. Each instance gets its ow

27、n copy of all the instance variables defined in the class, as the next figure shows. MyBike and YourBike are two different instances of the Bike class. Each instance has its own copy of the instance variables defined in the Bike class but has different values for these variables. In addition to inst

28、ance variables, classes can define class variables. A class wariable contains information that is shared by all instances of the class. For example, suppose that all bicycles had the same number of gears. In this case, defining an instance variable to hold the number of gears is inefficient; each in

29、stance would have its own copy of the variable, but the value would be the same for every instance. In such situations, you can define a class variable that contains the number of gears (see the following figure); all instances share this variable. If one object changes the variable, it changes for

30、all other objects of that type. YourBike, an instance of Bike, has access to the numberOfGears variable in the Bike class; however, the YourBike instance does not have a copy of this class variable. A class can also declare class methods You can invoke a class method directly from the class, whereas

31、 you must invoke instance methods on a particular instance. The Understanding Instance and Class Members section discusses instance variables and methods and class variables and methods in detail. Objects provide the benefit of modularity and information-hiding. Classes provide the benefit of reusab

32、ility. Bicycle manufacturers use the same blueprint over and over again to build lots of bicycles. Software programmers use the same class, and thus the same code, over and over again to create many objects. Objects versus Classes Youve probably noticed that the illustrations of objects and classes look very similar. And indeed, the difference between classes and objects is often the source of some confusion. In the real world, its obvious that classes are not themselves the objects they describe; that is, a blueprint of a bicycle is not a

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1