In UML modeling, a dependency relationship is a relationship in which changes to one model element (the supplier) impact another model element (the client). You can use dependency relationships in class diagrams, component diagrams, deployment diagrams, and use case diagrams.
You can also use a dependency relationship to represent precedence, where one model element must precede another.
Dependency relationships usually do not have names.
As the following figure illustrates, a dependency is displayed in the diagram editor as a dashed line with an open arrow that points from the client model element to the supplier model element.
Because a dependency relationship can represent several different types of relationships, keywords or stereotypes are used to show the precise nature of the dependency.
Type of dependency | Keyword or Stereotype | Description |
---|---|---|
Abstraction | «abstraction», «derive», «refine», or «trace» | Relates two model elements, or sets of model elements, that represent the same concept at different levels of abstraction, or from different viewpoints. |
Binding | «bind» | Connects template arguments to template parameters to create model elements from templates. |
Realization | «realize» | Indicates that the client model element is an implementation of the supplier model element, and the supplier model element is the specification. |
Substitution | «substitute» | Indicates that the client model element takes the place of the supplier. The client model element must conform to the contract or interface that the supplier model element establishes. |
Usage | «use», «call», «create», «instantiate», or «send» | Indicates that one model element requires another model element for its full implementation or operation. |
You can add dependency relationships to your model to accomplish the following goals:
In an e-commerce application, a Cart class depends on a Product class because the Cart class uses the Product class as a parameter for an add operation. In a class diagram, a dependency relationship points from the Cart class to the Product class. The Cart class is, therefore, the client model element, and the Product class is the supplier model element. This relationship indicates that a change to the Product class might require a change to the Cart class.