When duplicate functions appear during object-oriented implementation You may be wondering how to put it together. As a method, "generalization" that creates a class with the common part as a parent There is a "delegation" that cuts out the common part into an outer class and refers to it.
In general, ** delegation ** is better. The reason is that in the relation of ** inheritance **, it can be reused only by parent and child, but if it is ** delegation **, it can be reused from other classes. In terms of inheritance and generalization, it is said that changing the superclass will affect children and increase the range of influence. Also, the degree of coupling between superclasses and subclasses is stronger than delegation, and delegation also maintains independence.