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?
Unless it's a simple value attribute, like a number or a string, always use an association.
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..*]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With