An introduction to object-oriented programming
OOP (object oriented programing) programming is the use of "classes" and "objects" to create various models to achieve a real-world description. Object-oriented can make the program more extensible and easy to modify,
Make our development more efficient. Object-oriented programs make it easier for people to understand your code logic and make team development easier
Nouns in object-oriented
Class: A class is an abstraction, Blueprint, prototype, template for a class of objects that have the same properties. The properties of these objects are defined in the class (variables (data)), common methods
Attributes: Human beings contain many characteristics, which are described by programs, called attributes, such as age, height, gender, name, etc. are called attributes, and a class can have multiple properties
Methods: Human beings not only have height, age, sex these attributes, but also can do a lot of things, such as talking, walking, eating and so on, compared to the attribute is a noun, talking, walking is a verb, these verbs are described by the procedure is called method.
Instance (object): An object is an instantiated instance of a class, a class must be instantiated before it can be called in the program, a class can instantiate multiple objects, each object can also have different properties, like human refers to everyone, each person refers to the specific object, people and people before there is a common, there are different
Instantiation: The process of turning a class into an object is called instantiation
Three major features in object-oriented
1 Encapsulation: Assignment of data in a class, internal invocation is transparent to external users, which makes the class into a capsule or container, in which the data and methods of the class are contained.
2 Inheritance: A class can derive subclasses, properties, methods defined in the parent class, automatic quilt class inheritance
3 polymorphic: Polymorphism is an important feature of object-oriented, simple point: "An interface, a variety of implementations", refers to a base class derived from a different subclass, and each subclass inherits the same method name while the parent class method to do a different implementation, this is the same thing shows a variety of forms.
Object-oriented Python