Abstract and inheritance relationships allow reuse of concepts and definitions; polymorphism allows reuse of implementations and applications;
The principle of open-closed principle OCP is that a software entity should be open to extensions and closed to modifications.
Principle of encapsulation of variation (1) a variability is not mixed with another one (2) a variability should not be dispersedCode.
Liskov substitution principle: any base class can appear.
Dependence inversion: dependent on abstraction and implementation.
Combination/aggregation Reuse Principle (composite/aggregate Reuse Principle): use combination/aggregation as much as possible, rather than inheritance relationships.
Dimit Law: A software entity should have as few relationships as possible with other software entities.
Interface segregation principle: Provides the client with as few independent interfaces as possible, rather than a large total interface.
When does Coad Principle Use inheritance reuse?
(1) subclass is a special category of superclass. It is not a role of a superclass. It is distinguished by is-a and has-.
(2) Extend the super class responsibilities of sub-classes, rather than replacing them.
(3) There will never be a situation where you need to replace a subclass with a subclass of another class.
(4) inheritance is used only when the classification is meaningful. do not inherit from the tool class.
Several factory models solve the dependency reversal principle during object creation.
Abstract class purpose:
(1) If a specific class is not used for inheritance, try to inherit from an abstract class.
(2) abstract classes have as much code and as little data as possible