Prev | Next |
Parameterized Classes (Templates)
Enterprise Architect supports parameterized (Template) 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++.
The functionality of a template Class can 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 |
Click on the required Class. |
2 |
Select the 'Design > Element > Manage > Template Parameters' ribbon option. The 'Templates' dialog displays. |
3 |
In the 'Template Parameter(s)' panel, click on the . The 'Template Parameter' dialog displays. |
4 |
Type in the name and type of the parameter and, if required, click on the button 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.
OMG UML Specification
The OMG Unified Modeling Language specification, (v2.5.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.