python-Base Object-oriented

Source: Internet
Author: User

Catalogue1. Introduction to Object-oriented programming2. Why should I use object-oriented development? 3. Object-oriented features: encapsulation, inheritance, polymorphism4. Classes, Methods1. Introduction to Object-oriented programming  OOP (object oriented programing Programming is the use of "class" and "object" to create a variety of models to achieve a real-world description, the use of object-oriented programming because it can make the maintenance and extension of the program easier, and can greatly improve the efficiency of program development , in addition, An object-oriented program can make it easier for people to understand your code logic and make team development easier. the core features of object-oriented are as follows:  
Class Templates of the same property
Object objects Instances that are instantiated through a class (template). A class is instantiated before it can be called in a program. A class can instantiate multiple objects. Each object can have different properties
Encapsulation Package

Contains the data and methods of the class. The assignment of data in a class. Internal calls are transparent to external users

1. Prevent data from being arbitrarily modified

2. External procedures do not need to focus on the structure of the object. Logical structure. You only need direct access through the interface provided externally by this object.

Inheritance inheritance Subclass inherits the method of the parent class (note: can be overridden)
Polymorphism Polymorphism

An interface. Multiple forms (Implementation)

A different subclass is derived from a parent class. Each subclass inherits the same method name and does not implement each method name at the same time. Multiple forms of the same thing

No matter what the form of programming, we have to clearly remember the following principles:
Writing duplicate code is a very bad low-level behavior.
The code you write needs to change frequently.

In the development must try to avoid writing duplicate code, otherwise it is equivalent to dig a hole for themselves.

When developing a regular program. Write code must follow the principle of easy to read, easy to change (professional data called readability, easy to expand).

If you copy and paste a piece of the same code into multiple places of the program to invoke this function in various parts of the program, you will need to change it in many places in the future. Because if you accidentally missed a place and didn't change it, That could lead to a problem with the entire program running. In the development must try to avoid writing duplicate code, otherwise it is equivalent to dig a hole for themselves.

The main role of OOP programming is to make your code modifications and extensions easier

python-Base Object-oriented

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.