Skip to content

Latest commit

 

History

History
7 lines (5 loc) · 556 Bytes

inheritance-vs-composition.md

File metadata and controls

7 lines (5 loc) · 556 Bytes

Inheritance vs Composition

It depends on the case. The issue with inheritance is that it breaks encapsulation and creates a tight coupling between the parent class and subclasses.
We might end up also with a single big class. On the other hand, with the composition, we might end up with a lot of small classes. If the relation between the object is is a and we.
want to have slightly different behavior, I would choose inheritance. In other cases, I would choose a composition.