Object-oriented (OO) Basics and principles

Source: Internet
Author: User

Object-oriented basics:

OO Basics Understanding Implementation Method
Encapsulation Encapsulate objective things into abstract classes, and classes can only allow trusted classes or object operations for their own data and methods to hide untrusted information.  
Inheritance You can use all the functions of an existing class and extend these functions without re-writing the original class. Inheritance concepts can be implemented in three ways: Implementation inheritance, interface inheritance, and visual inheritance.
Polymorphism The technology that sets a parent object to be equal to one or more other sub-objects. After a value is assigned, the parent object can operate in different ways based on the features assigned to its sub-objects. There are two methods to achieve polymorphism: overwrite and reload.

Object-oriented principle:

OO principles Understanding
Single Responsibility Principle For a class, there should be only one reason for its change.
Open-closed Principle Class should be open to the extension and closed with multiple modifications
Liskov replacement principle Subclass should be able to replace the parent class and appear anywhere the parent class can appear.
Dependency inversion principle
Interface isolation principle Using multiple interfaces related to a specific customer class is better than using a common interface that covers multiple business methods.


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.