Dependency Relationships
A dependency relationship indicates that a change to one model element (the supplier) may cause a change in the other model element (the consumer). The supplier model element is independent because a change in the consumer does not affect it. In contrast, the consumer model element is dependent on the supplier model element because a change to the supplier may also affect it.
In an e-commerce application, for example, a "Cart" class depends on a "Product" class because the "Product" class is used as a parameter for an "add" operation in the "Cart" class. In a class diagram, a dependency relationship points from the "Cart" class to the "Product" class. In other words, the "Cart" class is the consumer model element, and the "Product" class is the supplier model element. This relationship indicates that a change to the "Product" class may require a change to the "Cart" class.
Connector
A dependency appears as a dashed line with an open arrow. It points from the consumer model element to the supplier model element.
Types of Dependency Relationships
Because a dependency relationship may represent several different types of relationships, you typically use a keyword or stereotype to show the precise nature of the dependency.
Type |
Keyword/Stereotype |
Description |
«abstraction», «derive», «realize», «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. | |
«bind» |
Binds template arguments to template parameters in order to create model elements from templates. | |
«access», «friend», or «import» |
Grants permission for one model element to reference the model elements owned by another model element. | |
«call», «create», «friendusage», «instantiate», «send», or «use» |
Indicates that one model element requires the presence of another model element for its correct implementation or functioning. |
Note A number of relationships use a connector similar to that of a dependency relationship but are not considered types of dependency relationships. These relationships include Extend Relationships, Include Relationships, and Note Attachments.
Using Dependency Relationships
You can add dependency relationships to your model to do the following:
-
Connect two packages to indicate that at least one model element in the consumer package is dependent on one model element in the supplier package. The dependency relationship does not indicate that all model elements in the consumer package are dependent.
-
Connect two classes to indicate that there is a connection between them that is more temporary than an association relationship. For details on association relationships, see Association Relationships. Specifically, a dependency relationship indicates that the consumer class does one of the following: temporarily uses a supplier class that has global scope, temporarily uses a supplier class as a parameter for one of its operations, temporarily uses a supplier class as a local variable for one of its operations, or sends a message to a supplier class.
-
Connect components to interfaces or other components to indicate that they use one or more of the operations specified by the interface or depend on the other component during compilation.
The dependency relationships in a model appear in a variety of diagrams, including class, component, deployment, and use-case diagrams.
Related Topics
- Adding and Modifying Relationships
- Working with Class Diagrams
- Working with Component Diagrams
- Working with Deployment Diagrams
- Working with Use-Case Diagrams
- Keywords
- Packages
- Stereotypes
|