Role Names

I l @ ve RuBoard

Role Names

The end of an association where it connects to a class is called an association role. Role names can be used instead of association names. A role name is a noun that denotes the purpose or capacity wherein one class associates with another. The role name is placed on the association near the class that it modifies, and may be placed on one or both ends of an association line. It is not necessary to have both a role name and an association name.

CREATING ROLE NAMES IN RATIONAL ROSE

graphics/quatranirose_icon.gif
  1. Right-click on the relationship line near the class that it modifies to make the shortcut menu visible.

  2. Select the Role Name menu choice.

  3. Enter the name of the role.

Figure 6-6 shows an association with a role name.

Figure 6-6. Role Name

graphics/06fig06.jpg

The relationship shown in Figure 6-6 is read in both directions.

  • A Professor playing the role of the Teacher is related to the CourseOffering

  • A CourseOffering is related to a Professor playing the role of a Teacher

There is no standard as to whether you should use association names or role names. However, most people today tend to use role names instead of association names since it is easier to convey the meaning of the relationship. This is especially true in a bidirectional relationship since it is very hard to find a verb phrase that reads correctly in both directions. What verb phrase could be used to name the association in Figure 6-6? By using a role name, the meaning is clear in both directions.

Associations are named or role names are used only when the names are needed for clarity. If you have a relationship between Company and Person then you could use an association name called "employs" or the role names of "Employer" and "Employee" to convey an employment relationship. If the classes were named Employer and Employee, no name would be necessary since the meaning of the relationship is clear based on the names of the classes.

I l @ ve RuBoard


Visual Modeling with Rational Rose 2002 and UML
Visual Modeling with Rational Rose 2002 and UML (3rd Edition)
ISBN: 0201729326
EAN: 2147483647
Year: 2002
Pages: 134

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net