The common terminology about OOP in four Python

Source: Internet
Author: User

Abstraction/Implementation

Abstract refers to the real world problems and entities of the nature of the performance, behavior and feature modeling, the establishment of a relevant subset, can be used to draw the program structure, so as to achieve this model. Abstractions include not only the data properties of this model, but also the interfaces of the data.

The implementation of an abstraction is the actualization of this data and its associated interfaces (realization). The process of actualization should be transparent and irrelevant to the client program.

Package/Interface

Encapsulation describes the idea of hiding data/information, which provides interfaces and access functions to data properties. The direct access to the data by any client, ignoring the interface, is the opposite of encapsulation, unless the programmer is allowed to do so. As part of the implementation, the client simply does not need to know how the data properties are organized after encapsulation. In Python, all class properties are public, but names can be "confused" to prevent unauthorized access, but that's all there is to prevent. This requires an interface to the data at design time to prevent the client from accessing the encapsulated data attributes through an irregular operation.

Note: Encapsulation is never equal to "hide something that you don't want others to see and maybe modify later."

The real package is, after deep thinking, making good abstractions, giving "complete and minimal" interfaces, and making internal details transparent to the outside

(Note: External transparency means that outside callers can get whatever functionality they want without being fully aware of the internal details)

Synthesis

The synthesis expands the reference to the class, which makes several different classes synthesize into a large class to solve the real problem. Synthesis of an unusually complex system, such as a class composed of other classes, smaller components may also be other classes, data properties and behavior, all together, each other is a "have a" relationship.

Derivation/inheritance/inheritance structure

Derivation describes a new attribute derived from a subclass that preserves all the required data and behavior in the existing class type, but allows modification or other custom actions without modifying the definition of the original class.
Inheritance describes a way in which a subclass attribute inherits from an ancestor class
The inheritance structure represents the derivation of many "generations", which can be described as a "genealogy", a contiguous subclass, which is related to the ancestor class.

Generalization/Specialization

Based on inheritance
Generalization means that all subclasses have the same characteristics as their parent classes and ancestor classes.
Specificity describes the customization of all subclasses, that is, what attributes make it different from their ancestor classes.

Polymorphism and polymorphism

Polymorphism refers to the multiple states of the same thing: water has many different states: ice, steam

The concept of polymorphism indicates how objects are manipulated and accessed through their common attributes and actions, without regard to their specific classes.

The ice, the water vapor, all inherit from the waters, and they all have a method of the same name to become the cloud, but the ice. to Cloud (), and vapor. Cloud () is a very different process, although the methods are all the same

Introspection/Reflection

Introspection, also known as reflection, shows how an object obtains its own information at run time. If you pass an object to you, you can find out what it is capable of, which is a powerful feature. If Python does not support some form of introspection, the Dir and type built-in functions will be difficult to work properly. And those special properties, like __dict__,__name__ and __doc__.

The common terminology about OOP in four Python

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.