Search code examples
umlclass-diagram

When two classes are associated, does one know the attributes of the other?


There are two classes: "Customer" and "Order". Those two classes are associated (1 to many). Should the Order class have a Customer instance as an attribute, or can we assume that the Order class has access to the Customer's attributes since they have been associated?


Solution

  • If there are two classes associated without any attributes along the association you may assume anything. Both may or may not see each other. It has not been specified.

    If you have a multiplicity along one side the other side can see as many as there are specified. That goes for both sides.

    Since you say there is a 1 to many relation the one side sees exactly one (has a single property of the other side's type). The other side respectively has many attributes or a list of references.

    enter image description here

    Customer sees many Orders and Order one Customer.

    Ah, and yes: when you have an association you can see the associated classes' public attributes.