I'm drawing a class diagram and noticed that sometimes I got a relationship (composition or aggregation) where the item uses the container, and sometimes not.What is the visual difference in a composition where the item class uses the container class vs where the item class doesn't know about the container class?
How to display in compositional relationship that the item knows about the container?
uml;concepts;class diagram
You can add an open arrow head to the composition or aggregation line, pointing toward the child to indicate directionality in the relationship. If the child knows about the parent, then simply don't include an arrow at all. I believe this works, because composition is a stronger form of an association link. The diamond indicates a composition or aggregation relationship. Without an arrow head, it can be read as either bidirectional or unspecified. Adding an arrow head makes it specific that the relationship is one-way.Keep in mind that it doesn't make sense for a parent to not know about its child since these relationships indicate a parent maintaining a collection of children, so an arrow head pointing to the parent doesn't make sense. The only two reasonable relationships are bidirectional (parent knows about child, child knows about parent) and a parent knows about child, but child doesn't know about parent directional.Directionality, indicating that the child does not know about the parent:Bidirectionality, indicating that the parent knows about the child (required for a composition or aggregation relationship) and the child knows about the parent, or indicating an unspecified relationship (I would expect the details about the child's member variables and methods to provide hints):