问题
I can't seem to find a decent answer on the interwebs, though I'm sure it's been asked before.
Basically, I have an object that is composed of another object - so black diamond and line. When the parent dies, the object it composes dies. However, the object that is it composed of has a pointer back to the parent. What does this look like in UML?
EDIT: For example, a building may be composed of rooms, but the rooms contain pointers back to the building object
Thanks
回答1:
You would use the owned end notation
which is showing a dot near the owning class in the association connector.
An end Property of an Association that is owned by an end Class or that is a navigableOwnedEnd of the Association indicates that the Association is navigable from the opposite ends; otherwise, the Association is not navigable from the opposite ends. Navigability means that instances participating in links at runtime (instances of an Association) can be accessed efficiently from instances at the other ends of the Association. The precise mechanism by which such efficient access is achieved is implementation specific. If an end is not navigable, access from the other ends may or may not be possible, and if it is, it might not be efficient.
From Superstructures ptc-13-09-05 p. 207
来源:https://stackoverflow.com/questions/31993606/uml-composition-with-bidirectional-association-composing-object-has-back-pointe