Design principles,

Source: Internet
Author: User

Design principles,

I. Single Responsibility Principle

For a class, there should be only one reason for its change. If you can think of more than one motivation to change a class, then this class has more than one responsibility.

Ii. Opening-closing Principle

Changes are closed and extensions are open. in the face of requirements, changes to the program are implemented by Adding Code, rather than changing the existing code to maintain relatively stable. how can this problem be achieved? Class that is most likely to change in prediction. Abstract isolation is constructed. When a class is not predicted, an abstract class is created to isolate it to avoid similar changes in the future.

Iii. Principle of dependency reversal

A: High-Level modules should not depend on low-level modules. Both of them should depend on abstraction.

B: Abstraction should not depend on details. Details should depend on abstraction (for interface programming, not for implementation programming ).

Iv. Li's replacement principle

The child type must be able to replace its parent type (because the child type can be replaced, the module that uses the parent class can be expanded without modification)

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.