11.4. Constraints
Stereotypes give roles to elements. Tagged values provide role-specific information enriching the element in its role. While atomically the element
|
11.5. UML Profiles
UML profiles combine the concepts of stereotypes, tagged values, and constraints to provide a
Figure 11-6 depicts a partial UML profile defining a stereotype with its associated tagged values and a couple of constraints, as you might receive in a vendor's documentation. The profile extends classes with a stereotyped class,
«EJBEntityBean»
. It extends attributes with two stereotyped attributes:
«EJBPrimaryKey»
and
«EJBCmpField»
. It declares the respective tagged values for the stereotyped classes and attributes, and it declares the enumeration,
transactionIsolationLevel
, to define the
Figure 11-6. A partial specification UML profile
Figure 11-7 shows a portion of a model using the profile declared in Figure 11-6. Figure 11-8 indicates how the tagged value structures in the model relate back to the profile declaration. The notes containing the tagged values make the notation bulky if you need to show a set of tagged values for every class, attribute, operation, and relationship.
When aiming to expose the structure and relationships of a system, class diagrams rarely show tagged values. Referring again to Figure 11-7, one tiny class having two attributes becomes a constellation of four diagram elements. A modest class diagram of 10 classes can easily require 100 extra notes to show the tagged values, hopelessly confusing the diagram and destroying its impact. Instead, modelers often maintain the tagged values
Figure 11-7. A stereotyped class and its stereotyped attributes, with their respective tagged values
Figure 11-8. The partial specification UML profile, showing model elements applying it
The UML from the profile and the model is shown in Figure 11-8. This illustrates the relationships between the declarations of the profile and a conforming model. The stereotypes in the profile extend the concept of an element. In this case, the stereotype
«EJBEntityBean»
extends ordinary classes, as shown (1) by the
|