What are stereotypes and tagged values
UML is designed to be a general-purpose language for diverse usage. Therefore, at times, it may not be able to serve some of the specific needs in describing your model elements. After all, one cannot be both general and specific at the same time. In such cases, you can make use of stereotypes, a UML extension mechanism, to characterize model elements. For example, you can create a stereotype and name it "External User" for users outside the system and add your own custom properties for domain-specific attributes by adding tag definitions. When applying a stereotype to your model element, you will specify the tag values to describe its characteristics.
Graphically, a stereotype is represented by a name enclosed by guillemets << >>. As shown in the example below, the stereotype External User is applied to a model element (i.e. actor) called Customer.
What this tutorial is about
In this tutorial, we will show you how to apply stereotypes to the actors (i.e. Customer, Cinema Manager) and add tag definitions, in the use case diagram below.
Steps to create stereotypes and add tag definitions
- Download Use-Case-Stereotype.vpp. You can also find this file at the bottom of this tutorial.
- Open the downloaded .vpp file in Visual Paradigm. To open a project, select Project > Open from the application toolbar.
- Open the only use case diagram in the project
- Right click on Customer. Select Stereotypes > Edit Stereotypes... from the popup menu.
- In the window opened, click Edit Stereotypes... under the Stereotypes tab.
- In the Configure Stereotypes window, click Add...
- In the Stereotype Specification window, select the General tab. Enter External User as the name of stereotype.
- Now let's just say that we want to have a way to describe whether an external user is using the ticketing system as a guest or a login user. So we are going to add a tag definition for actors that will apply this stereotype to specify the tagged value then Select the Tagged Value Definitions tab. Then click Add and select Boolean Tag.
- A new row will be inserted into the table for the new tag. Name it login user under the Name column. The type should be automatically filled in for you (i.e. Boolean). Click OK to close the Stereotype Specification window.
- In the Configure Stereotypes window, click OK. A window will open to ask you to confirm applying the changes. Click Yes to proceed.
- We are now finished with the stereotype definition. Click OK to close the Actor Specification window.
Apply stereotypes to model elements
Next we will apply the stereotype to a model element. Right click Customer and select Stereotypes > External User from the popup menu.
Graphically, the actor Customer will now appear with the text <<External User>> above its name.
Steps to set tagged values
We will now look at how to set the tagged values after we apply a stereotype (External User) to a model element (Customer).
- Right click on Customer and select Stereotypes > Edit Stereotypes... from the popup menu.
- In the Actor Specification window, select the Tagged Values tab.
- Click the cell under the Value column. Select the appropriate value for your need.
Note: After clicking a value cell, you may or may not get a list of values to choose from. It all depends on the type of the tag. For example, if the tag is of integer type, you would need to manually enter a number yourself.
- Click OK to accept the changes and close the window.
Create another stereotype
Follow the previous steps to create a stereotype off from Cinema Manager (actor) and name it Internal User.
As for the tag definitions, (instead of a boolean tag called "login user") let's add one of integer type to store the access level.
Then apply Internal User (stereotype) to Cinema Manager (actor). Simply right click on Cinema Manager and select Stereotypes > Internal User from the popup menu.
The text <<Internal User>> should now appear above the actor's name, Cinema Manager.