Software Design principles

Source: Internet
Author: User

First, high cohesion
1, LSP: Richter replacement principle, subclasses can replace instances of the parent class

2, OCP: Open closed principle, as far as possible by adding code to modify the function of the class, external----expansion of open, internal----modification closed.

3, DIP: Dependency inversion principle, a class as far as possible to rely on the interface and other high-end classes (parent class), try to avoid relying on subclasses.

4, SRP: A single responsibility principle, the less the better the function.


Two, loose coupling
1, LOD: Dimitri Rule, that is, friends least principle, in order to reduce the relationship between the interaction of the class

2, ISP: interface isolation principle, using a number of specialized interfaces, instead of using a single total interface, that is, the client should not rely on those it does not need to interface.
Based on the principle of interface isolation, when an interface is too large, we need to split it into smaller interfaces, and clients using that interface need only
Know the methods that are relevant to it. Each interface should assume a relatively independent role, do not do the things that should not do, the work should be done.

3, CARP: Synthetic polymerization multiplexing principle, that is, in a new object using some existing objects, so that they become part of the new object; new objects
The purpose of reusing existing functionality is achieved by delegating to these objects. It is designed to use composition/aggregation as much as possible and not to use inheritance.

Software Design principles

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.