how can I tell from class diagrams if a 1-to-N relationship implies a point to the parent on each child or a list of childs on the parent? Or both?
For example. If there is a client and a client has orders, is there anyway to tell from the UML class diagram what of the following implementations would be the case?
class Client {
array orders;
}
class Order {}
or
class Client {}
class Order {
client parent;
}
If the UML association is just a line, then you can't tell. But there are two ways to depict the difference in UML. The most common way is to show an arrowhead. This indicates what UML calls the 'navigability'. The class that owns the reference points to the referred class. The first alternative you mention would be depicted as follows:
The navigability arrow specifies that the Orders can be accessed efficiently from a Client, irrespective of how and why this is the case.
In recent versions of the UML specification, the dot notation has been introduced. The class that owns the reference has a dot on the opposite side of the association line (see UML 2.5 spec section 11.5.4). The first alternative you mention would be depicted as follows:
The dot specifies that Client has a property which is a list/array of Orders. Because this is a relatively newly introduced notation, it is not widely used.
You may combine dot and arrow, but I would say that a dot implies navigability (not the other way around).
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