Relations Between Objects Flashcards
Association is
a type of relationship in which one object uses or interacts with another. In UML diagrams the association relationship is shown by a simple arrow drawn from an object and
pointing to the object it uses.
having a bi-directional association is a
completely normal thing. In this case,
the arrow has a point at each end.
In general, you use an association to represent
something like
a field in a class.
Dependency is
a weaker variant of association that usually
implies that there’s no permanent link between objects.
Dependency typically (but not always) implies that an object
accepts another object as a method parameter, instantiates, or
uses another object.
how you can spot a dependency
between classes
a dependency exists between two classes if
changes to the definition of one class result in modifications
in another class.
Composition is
a “whole-part” relationship between two
objects, one of which is composed of one or more instances of
the other. The distinction between this relation and others is
that the component can only exist as a part of the container.
In UML the composition relationship is shown by a line with
a filled diamond at the container end and an arrow at the end
pointing toward the component.
Aggregation
is a less strict variant of composition, where one
object merely contains a reference to another. The contain-
er doesn’t control the life cycle of the component. The com-
ponent can exist without the container and can be linked to
several containers at the same time. In UML the aggregation
relationshipisdrawnthesameasforcomposition,butwithan
empty diamond at the arrow’s base.