Explore the object-oriented world

Article Directory

 


Preface

As we continue to learn, object-oriented thinking is applied by us. It is not only applied in programming and software development, but also extended to the fields of database, artificial intelligence, etc.


 

1. What is object-oriented?

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

Compared to process-oriented, it treats some methods and data as a whole, abstracts from a higher level, and is closer to the real world.

Two, the three elements of object-oriented

1. Package

Each object contains all the information it can operate and needs. This feature is called encapsulation

Two goals achieved by encapsulation: packaging and information hiding of data and behavior

The benefits of encapsulation: hide object properties and implementation details, control program access levels, and code reuse

2. Inheritance

Inheritance means that the subclass inherits the characteristics and behaviors of the parent class, so that the subclass object has the properties and methods of the parent class.

Limitations of inheritance: subclasses can be created to add new data. New functions, can inherit all the functions of the parent class, but cannot selectively inherit part of the functions of the parent class, and if the parent class changes, the child class has to change accordingly

3. Polymorphism

Polymorphism means that the same operation acts on different objects, can have different interpretations, and produce different execution results.

 

to sum up

Compared with traditional process-oriented object-oriented, the biggest advantage lies in the reusability of business logic, while object-oriented development also improves portability.

Guess you like

Origin blog.csdn.net/weixin_44693109/article/details/108321273