Object-oriented Principle

Source: Internet
Author: User

Single Responsibility Principle: For a class, there should be only one reason for its change

If a class assumes too many responsibilities, it is equivalent to coupling these responsibilities. This coupling will lead to a fragile design.

Open-closed Principle: For extensions, for modified closures

Dependency inversion principle: Abstraction should not depend on details. Details should depend on abstraction. To put it bluntly, it is necessary to program interfaces rather than implement programming.

Rishi replacement principle: child types must be able to replace their parent types. That is to say, in the software, all the parent classes are replaced with their child classes, and the program's behavior remains unchanged.

Dimit rule: In the structure design of classes, each class should minimize the access permissions of members, emphasizing the loose coupling between classes. The weaker the coupling between classes, the more conducive to reuse, A class in weak coupling is modified and will not affect related classes.

If the two classes do not need to communicate with each other directly, do not directly interact with each other. If one class needs to call the method of the other class, you can forward the call through a third party.

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.