Object-Oriented Programming principles

Source: Internet
Author: User

Object-Oriented Programming principles

1. Single Responsibility Principle (the principle of clear object responsibilities)

Requirement: a single object can only do one thing and must be focused. There are many reasons for too many responsibilities that may cause changes, and the program is unstable. (High Cohesion, low coupling extension)

2. Open and closed principles (Core Principles)

Requirement: the design of the class should be modified as little as possible when the requirement changes. Instead, the class can be extended. Closed modification and open Extension

3. Dependency inversion principle (object-oriented essence)

Requirement: Based on interface programming, the high-level module calls the interface and the underlying module implements the interface to prevent the underlying changes from directly affecting the high-level.

4. Interface isolation principle

Requirement: Use as many dedicated Small interfaces as possible instead of the total interface to avoid interface complexity.

5. Lee's replacement principle

Requirement: In the inheritance relationship, child classes can replace parent classes. virtual machines can dynamically find specific child class objects based on parent variables to achieve polymorphism.

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.