jeudi 3 février 2022

What does composition mean in the composition vs inheritance debate?

I was learning about the Bridge Design pattern. To quote:

The Bridge pattern attempts to solve this problem by switching from inheritance to the object composition. …

And then, the following image is shown:

Bridge Pattern

When people are talking about composition as an alternative for inheritance, do they refer to both aggregation and composition relationships? If not, what do they mean exactly?

I wonder this because the picture has an aggregation relationship between Color and Shape, not a composition one.

Aucun commentaire:

Enregistrer un commentaire