1. Introduction to Object Orientation
OOP programming is the use of "classes" and "objects" to create various models to describe the real world. The reason for using object-oriented programming is that it can make the maintenance and expansion of programs easier, and can greatly Improve the efficiency of program development, in addition, object-oriented programs can make it easier for people to understand your code logic, so that team development becomes more relaxed.
2. Object-oriented features
Class Class
A class is an abstraction, blueprint, and prototype of a class of objects with the same properties. The attributes (variables(data)) and common methods of these objects are defined in the class
Object
An object is an instantiated instance of a class. A class must be instantiated before it can be called in a program. A class can instantiate multiple objects, and each object can have different properties. Refers to all people, each person refers to a specific object, people have commonalities and differences between people
Encapsulation encapsulation
The assignment of data and internal calls in the class are transparent to external users, which makes the class a capsule or container, which contains the data and methods of the class
Inheritance Inheritance
A class can derive subclasses, and the properties and methods defined in the parent class are automatically inherited by the subclasses
Polymorphism Polymorphism
is an important feature of object-oriented. To put it simply, "one interface, multiple implementations" means that different subclasses are derived from a base class, and each subclass inherits the same method name. At the same time, the methods of the parent class are implemented differently, which is the various forms of the same thing.
3. Object-Oriented Grammar