Favov object composition over inheritance

The other major concept you should recognize is that of object composition. This is simply the construction of objects that contain others:
encapsulation of several objects inside another one. While many beginning
OO programmers use inheritance to solve every problem, as you begin to
write more elaborate programs, you will begin to appreciate the merits of
object composition.Your new object can have the interface that is best for
what you want to accomplish without having all the methods of the parent
classes. Thus, the second major precept suggested by Design Patterns is
Favor object composition over inheritance.

Leave a Reply

Your email address will not be published. Required fields are marked *