object-oriented concepts

Python is an object-oriented language. Object-oriented is a kind of abstraction. Abstraction refers to a way of looking at the world from a categorical perspective. To put it in JAVA’s programming philosophy: everything is an object. That is to say, in object-oriented, the transaction that constitutes the problem is decomposed into individual objects.

Object-oriented has three major characteristics, encapsulation, inheritance and polymorphism.

1. Two basic concepts of object-oriented

Class

is used to describe objects with the same properties and methods A collection of objects. It defines the properties and methods common to every object in the collection. Objects are instances of classes.

Object

Data structure instance defined through class

2. Three major characteristics of object-oriented

Inheritance

That is, a derived class inherits the fields and methods of the base class. Inheritance also allows an object of a derived class to be treated as a base class object.

For example: a Dog type object is derived from the Animal class, which simulates the "is-a" relationship (for example, Dog is an Animal).

Polymorphism

It refers to performing the same operation on variables of different types, and it will vary depending on the type of object (or class) And exhibit different behaviors.

Encapsulation

"Encapsulation" is to combine the abstracted data and behavior (or function) to form an organic whole (i.e. class) ; The purpose of encapsulation is to enhance security and simplify programming. Users do not need to know the specific implementation details, but only need to use the members of the class through the external interface and a specific access permission.

Continuing Learning
||
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!