Object-oriented program design
The advantage is that it solves the extensibility of the program. A single modification of an object is immediately reflected in the entire system, such as the character of a character parameter in the game and the ability to modify it easily.
Cons: Poor controllability, inability to process-oriented programming pipelining can accurately predict the problem of the processing process and results, the object-oriented program once started by the interaction between the object to solve the problem, even God can not predict the end result. So we often see a game of people changes in a certain parameter is likely to lead to the ability of the bully to appear, a knife to kill 3 people, the game is out of balance.
Application scenario: frequently changing requirements of the software, the general needs of the changes are concentrated in the user layer, Internet applications, enterprise internal software, games, etc. are the object-oriented programming of the good place
Object-oriented programming is not all. For a software quality, object-oriented programming is just to solve extensibility.
Extracting similar parts from a set of objects is a combination of features and skills that all objects of a class have.
In Python, a variable represents a feature, a function represents a skill, and a class is a combination of a variable and a function, and an object is a combination of a variable and a method (a function that points to a class).
A class is a combination of data and a function, which is called a property of a class
A class has two functions: property Reference and instantiation
>>> garen.camp # Reference class's Data property, which is shared with all objects/instances
'demacia'
>>> Garen.attack # A function property of a reference class that also shares
<function Garen.attack at 0x101356510>
>>> garen.name='garen' # Add Property
>>> del garen.name # Delete property
Object/instance has only one function: Property reference
The object/instance itself has only data properties, But Python's class mechanism binds a function of a class to an object, called a method of an object, or a binding method, a binding method uniquely binds an object, and a method of the same class binds to a different object,
different methods, memory addresses are not the same
The special thing about object binding methods is that Obj.func () passes obj to the first argument of Func.
Creating an object/instance creates an object/instance namespace that holds the name of the object/instance, called the object/instance property
In the Obj.name will first find the name in Obj's own namespace, can not find the class to find, the class can not find the parent class ... Throw an exception if you can't find it at the end
Object-oriented Python