Parameterized Classes (Templates)

Description

Enterprise Architect supports template or parameterized Classes, which specify parameters that must be defined by any binding Class.

Parameterized Classes are commonly implemented in C++; Enterprise Architect imports and generates templated Classes for C++.

A template Class enables its functionality to be reused by any bound Class. If a default value is specified for a parameter, and a binding Class doesn't provide a value for that parameter, the default is used.

Create a parameterized Class

Step

Action

1

Display the Properties dialog for the required Class.

 

2

Select the Templates page.

 

3

In the Template Parameter(s) panel, click on the Add button.

The Template Parameter dialog displays.

 

4

Type in the name and type of the parameter and, if required, click on the ( ... )  buttons after the Constraints and Default fields to select the required constraining and default Classes from the Select <Item> dialog.

The default Class can be either the constraining classifier or any Class that derives from the constraining classifier.

 

Notation Example

On a diagram, template Classes are shown with the parameters in a dashed outline box in the upper right corner of the Class.

ExampleofaParameterizedClass

OMG UML Specification:

The OMG UML specification (UML Superstructure Specification, v2.1.1, p. 622) states:

A template is a parameterized element that can be used to generate other model elements using TemplateBinding relationships. The template parameters for the template signature specify the formal parameters that will be substituted by actual parameters (or the default) in a binding.