Search code examples
umlclass-diagram

Representing something like address example


I have a confusion about UML in my class diagram. A person has 2 address, the first is obligatory, the second is not. How do I represent that?


Solution

  • An address should be better not modeled as a class that represents an object type, but as a complex datatype, which is represented as a class rectangle stereotyped with <<dataType>>. For modeling attributes having such a datatype, you wouldn't use any association in the class diagram, but simply use the name of your complex datatype Address as the range/datatype of your attributes primaryAddress and secondaryAddress.