An attribute is a named property of a Class that describes a range of values that can be held by the instances of that Class. You can specify attribute properties in the attribute's Specification window. Specifying attribute properties include changing the name, defining the type, converting the attribute to a port, etc. In the same window, you can find the description of each property. Descriptions are presented in the description area of the Specification window at the bottom of the Specification window.

More information

New Attribute


To create a new attribute


There are quite a few ways to create a new attribute, so do one of the following:

  • In the Containment tree, right-click a Class element, from the shortcut menu, select Create Element and then click Property, name it and press Enter.
  • In the Class's Specification window, click Attributes on the left side of the window and then click the Create button. The Attribute Specification window opens. Type a desired name, then click Close. You will see the change directly on your Class symbol.
  • On the diagram pane, click the Class shape, press the Ctrl+Alt+A shortcut keys and type the Attribute’s name and press Enter.
  • On the diagram pane, click the Class shape and then click the Create Property, which is the white-circled plus on the side of the Class block, name your attribute and press Enter.
  • On the diagram pane, click the Class shape, then click the Create Element button, which the black-circled plus on the side of the Class block. From the popped-up menu, select the Property command, name your attribute and press Enter


Attribute Name

The attribute's name must be unique in the Class scope. Nevertheless, do one of the following instructions to change the attribute's name

Warning

Illegal characters for attribute names are ( ) [ ] { } ! @ # % ; ', ; : ' " ?


Example of changing the attribute name from 'country' to 'Country' 

To change an attribute name


  • Click the Attribute in the selected Class on the diagram pane or in the Browser tree. Type a new name.
  • Click on the Class block, double-click on the Attribute, and on the Attribute Specification window, change the name and click Close.


Attribute Type


Attribute Type

The attribute's type can be any of these: Class, Interface, or Primitive Class, such as int or double. You are allowed to define the attribute's type.


To define the type of an attribute


  • Do one of the following:
    • Open the Specification window of an Attribute in your Class block, by right-clicking on the Attribute, and click on the cell of the Type property value. Then click the  button. In the opened window, select the type. Click OK.
    • On the diagram pane, right-click the Attribute, and then point to Type. In the opened list, select the type or point to New to create a new type.
    • On the Class shape, click the Attribute, and then on the smart manipulator toolbar, click the  button. In the opened list, select the desired type.
    • On the Class shape, click the Attribute, and then click the Attribute the second time. After the Attribute name, type a colon ":" and then type in the name of the new attribute type. Click Enter or click anywhere on the diagram. The type is now created and assigned.

Colon

Type the colon ":" , press Ctrl+Space or Ctrl+Backspace, and then in the open list, select the type.

  • In the Containment tree, select an element and drag it to the Attribute on the diagram.


Additional Information About Attribute Type


To add additional information about the type of an attribute


  1. Open the Attribute Specification window, by right-clicking on the Attribute. 
  2. In the top right corner of the window, select Expert in the Properties drop-down menu.
  3. In the Type Modifier list, select a particular sign in the:
    1. & - one class has a reference to other model elements.
    2. * - one class has a pointer to other model elements.
    3. [] - one class has an array of other model elements.


Attribute Visibility


Visibility NameFunction
Public '+'An attribute can be accessed by any other elements.
Package '~'An attribute can be accessed by elements from the same package.
Protected '#'An attribute can be accessed from the inside of the selected class and classes derived from that class.
Private '-'An attribute can be accessed only from inside of that class.

Visibility

The attribute visibility is shown at the attribute signature.


To set the attribute visibility


Do one of the following:

  • Type '+', '~', '-', or '#' visibility marks just before an Attribute name directly on a diagram.
  • Open the Attribute Specification window. From the Visibility drop-down list, select the desired item: public, package, protected, or private.


Attribute Scope


To set an attribute scope


  1. Open the Attribute Specification window.
  2. In the top right corner of the window, select Expert in the Properties drop-down menu.
  3. Select the Is Static check box to true.


Attribute Multiplicity


To set the attribute multiplicity


  1. Open the Attribute Specification window.
  2. In the top right corner of the window, select Expert in the Properties drop-down menu.
  3. Select or set the multiplicity value for the Multiplicity field.


Attribute Changeability 


The attribute changeability controls the access by operations on the class on the opposite end.

NameFunction
Is Read Only

When false - no restrictions on modifications.

When true - the value can not be altered after the object is instantiated and its values initialized. No additional values can be added to a set.


To set the attribute changeability 


  1. Open the Attribute Specification window.
  2. In the top right corner of the window, select Expert in the Properties drop-down menu.
  3. Select the Is Read Only check box to true.


Convert Attribute To Association 


Converting an Attribute

Keep in mind a few things about an attribute when converting it to an association:

  • the attribute has to have a type specified, and
  • the attribute is not a member end of some association.


To convert an attribute to an association


  1. On a diagram pane, select a Class with an Attribute, or select an Attribute itself.
  2. From the Class's or Attribute's shortcut menu, select the Refactor command, then Convert To, and Association.
  3. On the diagram pane, the Attribute is represented as an association with a role.

Logitics

You can move attributes back to the class by dragging and dropping them on the class shape.


Convert Attribute To Port


To convert to a port 


  1. Right-click an Attribute or multiple Attributes.
  2. On their shortcut menu, click Refactor > Convert To > Port.