Home>Article> What are the characteristics of object-oriented

What are the characteristics of object-oriented

青灯夜游
青灯夜游 Original
2019-06-03 14:45:23 182766browse

The characteristics of object-oriented are: 1. "Abstraction", extracting a certain type of thing in the real world and expressing it with program code; 2. "Encapsulation", surrounding the process and data, and Data can only be accessed through defined interfaces; 3. "Inheritance", a hierarchical model that connects classes; 4. "Polymorphism", allowing objects of different types to respond to the same message.

What are the characteristics of object-oriented

The operating environment of this tutorial: Windows 7 system, Dell G3 computer.

Object-oriented is a method of understanding and abstracting the real world. It is the product of the development of computer programming technology to a certain stage. It is a software development method

Object-oriented mainly has four major characteristics

1. Abstraction

Ignore the differences between a topic and the current Focus on things that have nothing to do with the goal and focus on aspects related to the current goal. (It means extracting a certain type of thing in the real world and expressing it in program code. The abstracted thing is generally called a class or interface). Abstraction does not intend to understand the entire problem, but to select a part of it and leave out some details for the time being. Abstraction includes two aspects, one is data abstraction, but the other is process abstraction.

Data abstraction -->Representing the characteristics of a type of thing in the world is the properties of the object. For example, a bird has wings, feathers, etc. (class attributes)

Procedural abstraction --> Representing the behavior of a type of thing in the world is the behavior of the object. For example, birds can fly and sing (class methods)

2. Encapsulation

Encapsulation is one of the characteristics of object-oriented and the main feature of object and class concepts. . Encapsulation is to surround the process and data, and access to the data can only be through the defined interface. For example, private variables can be obtained using set and get methods.

Encapsulation ensures that the module has better independence, making program maintenance and modification easier. Modifications to the application are limited to the interior of the class, thus minimizing the impact of application modifications.

3. Inheritance

A hierarchical model that connects classes, allows and encourages the reuse of classes, and provides a way to clearly express commonalities. A new class of an object can be derived from an existing class, a process called class inheritance. The new class inherits the characteristics of the original class. The new class is called the derived class (subclass) of the original class, and the original class is called the base class (parent class) of the new class. A derived class can inherit methods and instance variables from its parent class, and the class can modify or add new methods to make it more suitable for special needs. Therefore, it can be said that inheritance is to reuse parent class code and prepare for polymorphism.

4. Polymorphism

Polymorphism refers to allowing objects of different types to respond to the same message. Polymorphism includes parameterized polymorphism and containment polymorphism. Polymorphic languages have the advantages of flexibility/abstraction/behavior sharing/code sharing, and can well solve the problem of application functions having the same name. In general, method overriding, overloading and dynamic linking constitute polymorphism. One of the reasons why Java introduced the concept of polymorphism is to make up for the functional deficiencies caused by single inheritance of classes.

Dynamic link --> For a method defined in the parent class, if the method is overridden in the subclass, then the reference of the parent class type will call the method in the subclass, which is dynamic linking.

Object-oriented programming has many advantages:

1. Short development time, high efficiency, high reliability, and the developed programs are more strong. Due to the reusability of object-oriented programming, mature class libraries can be widely used in applications, thus shortening development time.

2. Applications are easier to maintain, update and upgrade. Inheritance and encapsulation make the impact of application modifications more localized.

(If you need basic knowledge related to computer programming, you can refer to theProgramming Learningchannel)

The above is the detailed content of What are the characteristics of object-oriented. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn