Basic principles of design patterns

Source: Internet
Author: User
Single Responsibility Principle

(SRP) a class, it is best to do only one thing, there is only one reason for its change.

Open-closed Principle

(OCP: the open-closed principle) software entities (classes, modules, functions, etc.) should be extensible, but cannot be modified.

Dependency reversal Principle

(DIP) the content of this principle is: to rely on abstraction, not on specifics. Or, you need to program the interface instead of implementing the Program (program to an interface, not an implementation ). The high-level module should not depend on the underlying module, and both should depend on abstraction.

Rishi replacement principle

(Liskov substitution principle, LSP) in a software system, subclass should be able to replace any location where the base class can appear, and after replacement, the code will work normally.

Dumit principles

6. Least knowledge principle (LKP) Minimum knowledge principle, also known as "law of Demeter". If the two classes do not need to communicate with each other directly, they should not directly interact with each other. If one class needs to call the method of another class, it can be forwarded by 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.