Object-oriented Technology Fundamentals

Object-oriented Technology Fundamentals

 

2006-8-6      fantian830211@163.com

 

 

Preface

Having been learning English for a long time, and longing to be an employee of an international company, and then wrote the article about OO in English. In fact, I just want to improve my English. Concerning the article, many of its statements are original statements from some books or internet articles.

What is an object?

Definition: An object is a software bundle of variables and related methods. In my experience, objects are abstraction of real-world objects. Objects are key to understanding object-oriented technology. So deeply understanding what an object is could be vitally important for an object-oriented learner and developer.

Look around now and we can see many examples of real-word objects: My computer, my desk, etc. They share two characteristics: They all have state and behavior. For example, computer has state (color and weight) and behavior (play films). As mentioned above, software objects are abstraction of real-world objects, so do the software objects share two characteristics too. It maintains its state with in one or more variables. A variable is an item of data named by an identifier. It implements its behavior with methods. A method is a function associated with an object.

Here we have to refer to encapsulation: An object’s variables make up the center of the object, methods hide the center from other object in the program. Packaging an object’s variables within a protective custody of its methods is called encapsulation. Encapsulation is the localization of knowledge within a module. Because of the object encapsulate states and behaviors, so the object user can view the object as a black box providing services. Instance variables and methods can be added, deleted and changed, but as long as the services provided by the object remain the same, code that use the object can continue to use it without being written.

Object provides two primary benefits:

Modularity: The source code for an object can be written and maintained independently. Also, an object can be easily passed in a system.

Information hiding: An object has one or more public interface which other object can use to communicate with it. The object can maintains its private states and methods that can be changed in anytime without affecting any other objects depend on it.

What is a message?

A single object alone generally is not very useful. Instead, an object usually appears as a component of a large program or an application. Through the interaction of these objects, programmers achieve higher-order functionality and more complex behavior.

Software objects interact and communicate with each other by sending message to each other. A message consists of three parts:

1.  The object to which the message is addressed

2.  The name of the method to perform

3.  Any parameter needed by the method

These three parts of the message are enough for the receiving object to perform the desired method.

Messages provide two important benefits:

1.  An object’s behavior is expressed by its methods, so message passing supports all possible interactions between objects (aside from direct variables access).

2.  Object don’t need to in the same process even on the same machine to send message back and forth and receive messages from each other.

What is a class?

Definition: A class is a blueprint that defines the variables and methods common to all objects of a certain kind.

In the real word, we often have many objects of the same kind. For example, my computer is just one of many computers in the world. Using object-oriented technology, we say that my computer is an instance (An object of a particular class) of the class of objects known as computers. So we can take advantage of the fact that objects of the same kind are similar and we can create a blueprint for these objects. A software blueprint for the same kind of objects is called class; here we get the class definition as I motioned above.

In addition instance variables, class can define class variables. Class variables contain information that is shared by all instances the class. For example, static fields in Java. A class can also define class methods. We can invoke class methods directly from the class. For example, static methods in Java are class methods.

Object versus Class

We are probably noticed that the illustration of objects and classes look very similar. Sometimes, some confusion caused by we don’t know the difference between of classes and objects. A class is not shaded because it is a blueprint of an object rather than an object itself. An object is shaded, indicating that the object exists and you can use it. Finally, object provides the benefit of modularity and information-hiding. Class provides the benefit of reusability.

What is an interface?

In general, an interface is a device or a system that unrelated entities use to interact. For example, language is an interface between two people. Within Java, an interface is a type, like a class, an interface defines methods, unlike a class; an interface never implements any methods, instead, classes implement interface implement the methods defined by the interface. A class can implement multiple interfaces.

We use an interface to define a protocol of behavior that can be implemented by any class anywhere in the class hierarchy. Interfaces are useful for the following:

1. Capturing similarities among unrelated classes without artificially forcing a class relation ship.

2. Declaring methods that one or more classes are expected to implement.

3. Revealing an object’s programming without revealing its class.

4. Modeling multiple inheritances.

What is abstraction?

Definition: Abstraction is simplification of the real world. It is an important OO concept. It is the ability for a program to ignore some of the aspects information that is manipulating, in other words, the ability focus on the essential.

Abstraction is the process where ideas are distanced from concrete implementation of the objects. The concrete implementation will change but the abstraction layer will remain the same. For example, over the years our computer improved a lot, but the basic interface has not been changed. Hence your knowledge of computer is abstract.

What is inheritance?

Inheritance is the inclusion of behavior and state of a base class in the derived class so that they are accessible in that derived class. The existing class is called the super class and the derived class is called the subclass.

Inheritance offers the following benefits:

1. Subclasses provide specialized behaviors from the basis of common elements from the super class. Through using inheritance, programmers can reuse the code in the super class many times.

2.Programmers can implements particular super class called abstract class that defines common behavior.

What is polymorphism?

Polymorphism means the ability of a single variable of a given type to be used to reference objects of different types, and automatically call the method that is specific to the type of object the variable references.

Bibliography

1.  The Java tutorial

2.  Java/J2EE job interview companion

3.  Object-oriented software structure

 

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值