Is this UML Object Diagram allowed for this Class Diagram?

Viewed 51

I have this basic class diagram: Class Diagram

and was wondering whether this object diagram is allowed: Object Diagram

The class diagram is given and I was wondering whether it is possible to create an object diagram where two customers (maybe wife and husband) are sharing the same bank account with this structure. But because a composition is used, the bank account would get deleted if one of the owners gets deleted right? So this class diagram is not really suitable for shared accounts, right?

1 Answers

This scenario for the objects in the second diagram is indeed not valid. The reason is that composition implies an exclusive ownership.

For an account to be shared by several customers you’d have to change the class diagram, for example:

  • use aggregation instead of composition (white diamond). Although its semantics are not well defined in the UML specification, it allows in any case for shared ownership.
  • use a simple association (without diamond). You could express the fact that an account has several customers with an explicit multiplicity.
  • use a composite client: the client could either be a single person, or a group of several clients. This construct is more complex.
Related