OOD basically has 6 principles, and it is actually complementary, that is, some principles need to take advantage of other principles to achieve themselves. The six principles are as follows:
1) Open-Close PrinciPle (OCP), open-closed principles, is the design to have good support for extended extensions, and strict restrictions on the revision. This is the most important thing is the most abstract principle, basically what we said is based on this principles. Other principles are also a path for its implementation.
2) Liskov Substitual PrinciPle (LSP), Riviend replacement principles, very strict principles, rules are "subclasses must be able to replace the base class, otherwise it should not be designed as their subclasses." That is, the subclass can only go Extend base classes, rather than hidden or overwriting base classes, if designed in this regard should be replaced with the following two methods:
1.
2.
3) Dependence Inversion PrinciPle (DIP), dependent on the translation principle, "design is dependent on abstraction rather than avatar". In other words, we want to think with abstraction, rather than one class, which is what kind of classes I need to be docked. Because these are specific. What is the benefit of this? People's thinking is actually very abstract. When we analyze the problem, it is not a matter of explanation, but it is very abstract that the whole problem is conceived, so the abstract design is in good thinking. In addition, this principle will support OCP, and the abstract design makes us don't have to rely too much to rely on achieving, this extension is possible, this principle is also another article "Design By Contract" cornerstone.
4) Interface SegRegation PrinciPle (ISP), "Picking large interfaces into multiple small interfaces", so the advantage is obvious, I don't know if there is necessary to continue to describe, in order to save space, I actually I am actually The principle is just a small summary. If there is a need to understand more, it is recommended to see "Java and Mode", a masterpiece of MS MVP! ^ _ ^
5) Composition / Aggregation Reuse PrinciPle (CARP), the designer should first consider composite / aggregation, not inheritance (because it is intuitive, the first impression is "Oh, this is OO"). This is the so-called "Favor Composition Over Inheritance", which brings more benefits than inheritance in practice, so it is preferable to consider it.
6) Law of Demeter Or Least Knowlegde PrinciPle (LOD OR LKP), Dimit France or the Minimum Knowledge Principle, this principle is first formally used in the DEMETER system, so defined as Dimitzi. It is what "an object should understand other objects as little as possible." That is, another law on how to loosset coupling.