Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Association or List attribute in UML Class diagram?

I have identified two classes that I want to implement in code like this:

InsuranceProviders{ 
}

Advice{
    List<InsuranceProviders> providers;
}

If I wanted to represent these two classes in a UML class diagram, should the Advice class have an Association with InsuranceProvider, or should it have a list attribute of InsuranceProvider instead?

With Association

With Attribute

Or maybe something else?

like image 959
Robert Avatar asked Oct 20 '25 14:10

Robert


2 Answers

Unless it's a simple value attribute, like a number or a string, always use an association.

like image 76
Jim L. Avatar answered Oct 22 '25 03:10

Jim L.


You can choose. Both options are valid in UML. I would prefer the association, though, because in that case, the relationship between the two classes is more prominently visualized.

By the way, in your diagram 'With Association', you should position the text "+providers" near the InsuranceProvider class, not in the middle of the line.

In your diagram "With Attribute", you should notate the attribute as follows:

+providers: InsuranceProvider[0..*]

like image 42
www.admiraalit.nl Avatar answered Oct 22 '25 03:10

www.admiraalit.nl