DEV Community

Discussion on: Why composition is superior to inheritance as a way of sharing code

Collapse
 
lluismf profile image
Lluís Josep Martínez

The forget about the IS-A origin, in the real world a triangle is a kind of shape as well as a financial agent is a kind of person or a drug order is a kind of order. When defining entities belonging to a hierarchy I find it more natural to use inheritance instead of composition.