Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UML Can an interface be part of an aggregation relationship?

Tags:

uml

I have a top class, lets call it Car. I have an interface, lets call it ITyre and then I have two classes which implement ITyre. Lets call them Goodyear and Bridgestone.

Am I allowed to have a composition association between the interface ITyre and Car (from UML perspective, not a particular language)?

like image 771
Jean Avatar asked Oct 17 '25 13:10

Jean


1 Answers

If you meant,

public class Car
{
    ITyre something;
}

Yes, you can. In fact it will be good if you do it this way. So that your Car is not depending on any one particular concrete implementation. Your implementation here will give you flexibility to swap out tyres (DI or factory) irrespective of who built them.

like image 56
Pradeep Avatar answered Oct 21 '25 23:10

Pradeep