Binding Relationships

A binding relationship is a type of dependency relationship that assigns values to template parameters in order to generate a new model element (a class or collaboration) from the template (a template class or template collaboration). The template is the supplier in the relationship, and the model element is the consumer. The binding does not affect the template, so the template can be bound to any number of model elements. The binding does affect the model element, however, because the model element is defined by replacing the template parameters with the template arguments provided by the binding relationship.

For example, to create a "BookList" class from a "List" template class, you can add a binding relationship pointing from the "BookList" class to the "List" template class. The binding relationship provides "Book" (a class) and "50" (an integer value) as template arguments for the "List" template's "ItemType" and "Size" template parameters. (Note that these arguments must match the type specified by the template parameters. For details, see Understanding Template Arguments.) The new "BookList" class can thus contain 50 instances of the "Book" class.


Connector

A binding relationship appears as a dashed line with an arrow pointing from the model element to the template. The keyword «bind» appears next to the connector, and template arguments are placed in parentheses after the keyword.

Binding Relationship Between a Template Class and Class

 

Binding Relationship Between a Pattern and Collaboration

 


Using Binding Relationships

You can add binding relationships to your model to create new classes from template classes or to create new collaborations from template collaborations. The binding relationship allows you to assign values to the template parameters in the template class or template collaboration. The values assigned to template parameters are called template arguments. A template argument must correspond in type to the template parameter. For example, you must assign a template argument with a class value to a template parameter defined as a class type.

In most cases, a binding relationship provides one value for each template parameter. There are two exceptions: First, if a template parameter has been assigned a default template argument, you do not have to provide a template argument for it if you want the new model element to be defined by replacing the template parameter with its default. Second, some template collaborations have template parameters to which you can assign template arguments with multiple values. For instance, you can bind multiple classes to the observer template parameter in the observer pattern. For details, see Example Pattern and Understanding Template Arguments.

The binding relationships in a model usually appear in class diagrams.


Related Topics

Comments ( )
Link to this page: //www.vb-net.com/dotnet/relation/Binding.htm
< THANKS ME>