What is OOP

Source: Internet
Author: User

OOP (object-oriented-programming) is relative to the structural programming (Structure programming), which means that the object-oriented thinking is used for software programming. It is the most popular programming mode today. "Object-oriented" technology pursues the direct simulation of the real world by software system, as far as possible to map things in the real world directly to the solution space of software systems. Object-oriented programming differs from previous programming ideas because it takes a new concept-object as the foundation and component of the entire structure of program code. Class is the abstraction and generalization of objects, classes are the encapsulation of data, properties, and methods, and in some ways the class is like a control with no interface.
Object definition: An object is an entity in the real world. It has the following characteristics: There is a name to distinguish from the other objects; there is a state used to describe the characteristics of its dictation; there is a set of operations, each of which depends on a function or behavior of the object, and the operation of the object can be divided into two categories: one is the operation of one's own, the other is an operation added to the other object, is an independent entity of its own state characteristics and the operations that can be applied to these states.
For example, the following example:

The state of the object:
   object name: John
   Sex: Female
   height: 1.65 m
   Weight: 55 kg
function of object:
   answer weight answer
   height answer
   gender
   teach probability class
   as Tutor

In the computer world, an object can be viewed as an identifiable region in storage that holds a fixed or variable number of values. Object partitioning does not have a unique standard, it relies on the purpose of setting objects and the actions required. The state of an object is not entirely intended to serve the outside world, but it is itself a foundation for external service. So the characteristics of the object are as follows: module independence, that is, the internal state of the module is not changed by external interference, small dependencies between modules, each module can be composed of the combination of selection and reuse of the system, dynamic connectivity, that is, through the message activation mechanism, the dynamic linkage between the objects, so that the whole mechanism to operate, is called the object's connectivity, the maintainability, is the object's function is "hidden", the modification consummation function is limited to this object's interior, does not ripple to outside.

In an object-oriented system, the relationship between objects is passed through messages. Messages, which are the means by which objects request or collaborate with one another, are descriptions of the specifications that require an object to perform a function operation. It has the following properties:
(1) The same object can receive different forms of multiple messages, resulting in different responses;
(2) The same form of message can be given to different objects, the response can be different;
(3) The message can be sent without regard to the specific recipient, the object can respond to the message, can also ignore the message, the response to the message is not necessary.

Messages are divided into public and private messages, and messages sent directly to them by external objects are public messages, while those sent by themselves are not open to the outside world, and private messages need not be understood.

The above is a brief discussion of the object and some of its characteristics, and now we can propose the concept of class. A class is an abstraction of a set of objective objects that combines the common characteristics of a group of objects, including structural and behavioral characteristics, to illustrate the capabilities and nature of the group's objects. In the system composition of the computer world, the class forms a module with specific functions and a means of code sharing.

Object-oriented systems have three characteristics: encapsulation, inheritance, and polymorphism

Encapsulation: Putting together a data and a set of operations related to this data to form a dynamic entity-object, the user does not have to know the implementation details of the object's behavior, simply access the object based on the external characteristic interface provided by the object. The goal is to separate the user of the object from the designer, and the user does not have to know the details of the object's behavior, simply by using the Protocol command object provided by the designer.

Inheritance: Inheritance expresses the intersection of an object class. It enables a class of objects to inherit the features and capabilities of another class of objects.
If there are inheritance relationships between classes, they should have the following characteristics:
(1) Shared features between classes (including sharing between data and program code);
(2) There are subtle differences or additions between classes (including unshared program code and data);
(3) There is a hierarchy between classes.

Polymorphism: Polymorphism describes the same message that can be used in a variety of different ways depending on the message object being sent.

Therefore, object-oriented programs can be seen as the role of some objects with data and methods. The user needs to pay special attention to the selection and design of the class when designing the program.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.