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