Fast Track UML 2.0

A dependency is a "using" relationship within which a change in one thing (such as a class) may affect another thing (for instance, another class). The dependent element is called the client or source; the independent element is called the supplier or target.

A dependency involving two classes appears as a dashed line with a feathered arrow pointing at the supplier. Figure 2-16 shows an example of a dependency.

Figure 2-16: Dependency

If the definition of the Book class changes, the way that the checkAvailability function works may have to change as well.

The UML defines a number of stereotypes that apply to dependencies. These are explored in the following subsections.

Usage Dependencies

A usage dependency is one in which the client requires the presence of the supplier for its correct functioning or implementation.

You model a generic usage dependency using the ‚ «use ‚ » stereotype. Figure 2-17 shows that instances of the Order class require instances of the OrderItem class in order to function properly.

Figure 2-17: Usage dependency

The UML defines the following five types of usage dependencies:

Abstraction Dependencies

An abstraction dependency is one in which the client is at one level of abstraction and the supplier is at a different level.

You model a generic usage dependency using the ‚ «abstraction ‚ » stereotype. Figure 2-20 shows that the SShoppingCart class is more concrete than the ShoppingCart class. (A session bean is a type of EnterpriseJava Bean [EJB]. See Mastering Enterprise JavaBeans [1] for more information about EJBs.)

Figure 2-20: Abstraction dependency

The UML defines the following five types of abstraction dependencies:

Permission and Substitution Dependencies

A permission dependency ( ‚ «permit ‚ ») signifies that the supplier grants the client permission to access some or all of its constituent elements.

Within Figure 2-25, the Customer class grants the RecommendationEngine class access to its private attributes emailAddress and name .

Figure 2-25: Permission dependency

A substitution dependency ( ‚ «substitute ‚ ») signifies that the client will comply with the contract specified by the supplier at program execution time.

Within Figure 2-26, a more specific Login Page adheres to the basic frame-work within which a generic HTML Page works.

Figure 2-26: Substitution dependency

[1] Ed Roman, Mastering Enterprise JavaBeans (Second Edition) (New York, NY: John Wiley & Sons, 2001).

Категории