The advantage of object-oriented is the reuse of classes. Inheritance and polymorphism are the reuse of classes, a class-level reuse, and a method-level reuse. What are the similarities and differences between the two references to inheritance? is PHP really polymorphic? If not, then why not? What is the difference between some words and the polymorphism in other languages?
Inheritance and composition are all ways to improve code reusability. When you design a model, you can identify the composition and inheritance relationships between classes by language. From the perspective of method reuse, if there are many identical codes and methods in two classes, you can abstract a father from these two classes, provide a public method, and then two classes as subclasses, providing a personalized approach. At this point inheritance semantics are better. There are not so many restrictions on the combination. Classes between combinations can be relational (embodied as code reuse) with little or no relationship. However, in programming, the trade-offs between inheritance and composition are often not straightforward enough to determine whether they should be inherited or combined. Do you have any criteria? Yes, the standard is low coupling. Coupling is a measure of the degree of interconnection between different modules within a software structure, which is the dependency between different modules. Between the low-coupling batch module and the module, as far as possible to make the module independent existence, the module and the interface between the module as small and simple. Decoupling is to release the dependencies between the modules and modules.
Object-oriented inheritance and composition