Profile Diagrams

A profile allows UML to be extended for use with a particular programming platform (such as Microsoft's .NET framework or the Java Enterprise Edition platform), or to model systems intended for use in a particular domain (for example medicine, financial services or specialised engineering fields). A profile extends the UML to allow user-defined stereotypes, metaattributes, and constraints (see below). The vocabulary of the UML may thus be extended with a platform or domain-specific vocabulary that allows more meaningful names to be assigned to model elements. Code generation tools can use profiles to generate code targeted at a specific platform or environment (the precise way in which profiles are implemented depends somewhat on the UML modeling tool used). Here are the abbreviated definitions of the key terms mentioned above:

To understand how profiles work, it is necessary to understand the fundamental nature of the UML, which is that of a metamodel. The word model implies an abstraction of some real world system. The word meta implies some further abstraction of whatever concept we apply it to. The word metadata is often used in the context of a database, for example, and in simple terms means data about the data. A metamodel (as you might deduce) therefore describes the properties of a model. A model is constrained by its metamodel in the same way that a computer program is constrained by the grammar and syntax of the programming language used to write it. Every element of the Unified Modeling Language is defined by a metaclass.

A profile is a special kind of package that contains stereotypes. Each of these stereotypes defines the way in which a standard UML metaclass is to be extended in order to adapt it for use with a specific platform or domain, by providing additional tag definitions and constraints. A stereotype may extend more than one metaclass, and a metaclass may be extended by more than one stereotype, but a stereotype must always be used in conjunction with one of the metaclasses that it extends, and not in isolation. Stereotypes are represented on profile diagrams using class notation, except that the keyword «stereotype» appears above or in front of the name of the model element as shown below.


The model element DataType is a stereotype

The model element DataType is a stereotype


As stated above, a stereotype extends a UML metaclass and is therefore meaningless if viewed in isolation. In order to show that a stereotype extends a metaclass, the metaclass is also shown on the profile diagram. The diagram below tells us that the «DataType» stereotype extends the Class metaclass. The relationship between the stereotype and the metaclass it extends is indicated by a solid line connecting the stereotype icon to the metaclass icon, with a filled arrowhead pointing towards the metaclass end (this line is referred to in the UML Superstructure document as an extension). Note that the use of the «metaclass» stereotype is optional, but can help to make it a bit more obvious what is intended.


The DataType stereotype extends the Class metaclass

The DataType stereotype extends the Class metaclass


In the notation shown above we are saying that the DataType stereotype may be used to extend the Class metaclass. We might, in certain circumstances, want to stipulate that a particular metaclass must always be extended by a given stereotype. We can show that this is the case by adding the constraint {required} at the stereotype end of the extension. In the example shown below, an instance of the Module stereotype must always be linked to an instance of the Component metaclass.


The Module stereotype always extends the Component metaclass

The Module stereotype always extends the Component metaclass


A stereotype can be associated with a graphical icon. Some standard UML elements are already associated with a graphical icon, the classic example being the "stick man" used on use case diagrams (which are covered elsewhere) to represent instances of the Actor metaclass. If a stereotype defines a graphical icon, the icon may be attached to any model element extended by the stereotype. In fact, the icon can be used to replace the standard rectangular icons for model elements such as classes and components, provided the element in question is only extended by a single stereotype, and it is not deemed necessary to list any properties (i.e. attributes or operations) for the element.


A graphical icon is defined for the Book stereotype

A graphical icon is defined for the Book stereotype


The icon will also replace any existing standard graphical icon. A smaller version of the graphical icon may appear inside the rectangular icon used to represent a model element. The examples below show several ways of applying the Book stereotype to a model element, including two different ways of using the graphical icon.


Different notations for applying the Book stereotype to a model element

Different notations for applying the Book stereotype to a model element


Because a stereotype is essentially a metaclass, it can have properties which are known as metaattributes (in previous versions of UML these were known as tag definitions). When a stereotype is used to extend a metaclass, the metaattributes may be listed in a separate compartment below the stereotype name.


Metaattributes may be listed in a separate compartment

Metaattributes may be listed in a separate compartment


A stereotype may also generalise or specialise another stereotype, as shown below.


The Book stereotype is specialized by the Fiction and NonFiction stereotypes

The Book stereotype is specialized by the Fiction and NonFiction stereotypes


As mentioned above, a stereotype may be applied to more than one element, and multiple stereotypes may be applied to the same element. In the example below, the stereotype Server may be applied to both the Component metaclass and the Device metaclass. The Device metaclass may additionally be extended by the NetworkNode stereotype.


The application of stereotypes

The application of stereotypes


In the diagram below, the Server and NetworkNode stereotypes are applied to the WebServer model element. Note that the names of the applied stereotypes appear above the name of the model element, separated by commas (if the model element also has a keyword, this can be displayed either above or in front of any stereotype names). The attribute values for each of the applied stereotypes can be shown in a comment symbol that is attached to the model element.


Multiple stereotypes can be applied to a model element

Multiple stereotypes can be applied to a model element


As mentioned earlier, a profile is essentially a kind of package, and as you might expect it uses the same notation as a package. The keyword «profile» is used, either above or in front of the package name, to indicate that the package is a profile. Each profile consists of one or more stereotype definitions that extend an existing UML metaclass. In the Network profile illustrated below, the User stereotype extends the Class metaclass, and the NetworkNode stereotype extends the Device metaclass. The NetworkNode stereotype is specialised by the Workstation, Server and Switch/Router stereotypes.


The Network profile defines a number of stereotypes

The Network profile defines a number of stereotypes


A profile is applied to another package in order to make the stereotypes in the profile available to that package. The illustration below shows the Network, Telecomms and Software profiles being applied to the ITManagement package. The application of a profile is indicated by a dashed line from the package to the profile, with an open arrowhead pointing at the profile. The keyword «apply» is shown near the arrow, at the profile end. As you can see, multiple profiles can be applied to the same package (providing they do not have conflicting constraints). Once a profile has been applied to a package, the stereotypes defined by the profile can be applied by the package to model elements used by the package. If a profile is subsequently removed from a package, the stereotypes defined by the profile are also deleted from the package.


Profiles are applied to a package

Profiles are applied to a package