Template parameters and arguments

In UML models, template parameters are formal parameters that once bound to actual values, called template arguments, make templates usable model elements.

You can use template parameters to create general definitions of particular types of template. For example, when you add template parameters to a class, it becomes a template class (sometimes called a parameterized class). Using a template class as a general pattern, you can create a group of classes that use template parameters to define more specific behavior.

Every template parameter must have a name and a type. The name of the parameter must be unique in the template parameter list. The type is a reference to a type of model element (for example, a class, an interface, or an attribute) or to a primitive data type (for example, an Integer or a String). A template parameter can take a default value if you do not specify a template argument when you bind the parameter to the template.

As you bind a model element to a template, you assign values (called template arguments) to the template parameters. Template arguments replace template parameters in model elements that you bind to a template. This action creates a new model element that has the structure of the template and that uses the values of its template arguments.

The syntax of a template parameter is name : type.

The notation for a template parameter in the diagram editor is a box with a dashed border in the upper right corner of a classifier shape. The Project Explorer view lists template parameters under the classifier for which they are defined. The following table illustrates these two notations.

Template parameters in the diagram editor

Template Parameters in the Project Explorer view

A Cart class with two private template parameters: Class > Cart and Class > Class. The Project Explorer view, showing the Cart class and its template parameters. The parameters are contained in a private TemplateSignature class.