Home > Common Problem > What is object-oriented programming

What is object-oriented programming

angryTom
Release: 2019-08-12 16:14:59
Original
22948 people have browsed it

What is object-oriented programming

Object Oriented (OO) is a software development method. Object-oriented concepts and applications have transcended programming and software development and expanded to fields such as database systems, interactive interfaces, application structures, application platforms, distributed systems, network management structures, CAD technology, artificial intelligence and other fields. 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

Recommended tutorial:java development tutorial

Concept

⑴Object.

Objects are anything that people want to study. From the simplest integers to complex airplanes, they can be regarded as objects. They can not only represent specific things, but also abstract rules, plan or event.

⑵The state and behavior of the object.

Objects have state, and an object uses data values ​​to describe its state.

Objects also have operations, which are used to change the state of the object. The object and its operations are the behavior of the object.

The object realizes the combination of data and operations, so that the data and operations are encapsulated in the unity of the object

⑶ class.

The abstraction of objects with the same characteristics (data elements) and behavior (functions) is a class. Therefore, the abstraction of an object is a class, and the concretization of a class is an object. It can also be said that an instance of a class is an object, and a class is actually a data type.

Classes have attributes, which are abstractions of the state of objects. Data structures are used to describe the attributes of the class.

A class has an operation, which is an abstraction of the object's behavior, described by the operation name and the method to implement the operation.

⑷Class structure.

There are several categories in the objective world, and there are certain structural relationships between these categories. There are usually two main structural relationships, namely general-specific structural relationships and whole-part structural relationships.

 ①General--the specific structure is called a classification structure, which can also be said to be an "or" relationship or an "is a" relationship.

 ②The whole-part structure is called the assembly structure, and the relationship between them is an "and" relationship, or a "has a" relationship.

⑸Messages and methods.

The structure used to communicate between objects is called a message. In object operations, when a message is sent to an object, the message contains information for the receiving object to perform a certain operation. Sending a message must at least include the name of the object receiving the message and the name of the message sent to the object (i.e. object name, method name). Generally, the parameters must be explained. The parameters can be variable names known to the object that knows the message, or global variable names known to all objects.

The implementation process of operations in a class is called a method. A method has a method name, return value, parameters, and method body.

Features

⑴Object uniqueness.

Each object has its own unique identifier, through which the corresponding object can be found. During the entire lifetime of an object, its identity does not change, and different objects cannot have the same identity.

⑵Abstractness.

Abstraction refers to abstracting objects with consistent data structures (properties) and behaviors (operations) into classes. A class is an abstraction that reflects important properties related to an application while ignoring other irrelevant content. The division of any class is subjective, but must be related to the specific application.

⑶Inheritance.

Inheritance is a mechanism for subclasses to automatically share the data structures and methods of parent classes. This is a relationship between classes. When defining and implementing a class, you can do it on the basis of an existing class, take the content defined by the existing class as your own content, and add some new content.

Inheritance is the most important feature that distinguishes object-oriented programming languages ​​from other languages ​​and is not found in other languages.

In the class hierarchy, a subclass inherits only the data structure and methods of a parent class, which is called single inheritance.

In the class hierarchy, when a subclass inherits the data structures and methods of multiple parent classes, it is called multiple inheritance.

Multiple inheritance, JAVA, VB, NET, and Objective-C only support single inheritance. Note that when using multiple inheritance in C, you need to be careful about ambiguity.

In software development, the inheritance of classes makes the software created open and extensible. This is an effective method of organizing and classifying information. It simplifies the creation of objects and classes. volume, increasing code reusability.

Use inheritance to provide a standardized hierarchical structure of classes. Through the inheritance relationship of classes, public features can be shared, improving the reusability of software

⑷Polymorphism (polymorphism)

Polymorphism means that the same operation, function, or process can be applied to multiple types of objects and obtain different results. Different objects can produce different results when receiving the same message. This phenomenon is called polymorphism.

Polymorphism allows each object to respond to a common message in a way that suits it.

Polymorphism enhances software flexibility and reusability.

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template