Thursday, June 1, 2017

Work with classes and objects in UML static structure diagrams

Work with classes and objects in UML static structure diagrams

Add an interface to a class, component, or other element

  1. In a static structure, component, or deployment diagram, drag the lollipop Interface shape (represented by a line and circle) onto the drawing page.

  2. Glue the endpoint without the circle to a connection point Connection point image - blue X on the class component, or other element.

  3. Double-click the Interface shape to add a name, operations, and other property values.

    Tip: You can also represent an interface with a rectangular Interface shape that resembles a class. Use this shape when you want to display a list of the interface operations.

    Tip: To change the type of shape that appears for an interface, right-click the Interface shape and click Show as Class-like Interface or Show as Lollipop Interface.

Indicate a realizes relationship between a class and an interface or other element

  1. In a static structure diagram, right-click any class shape (Class, Parameterized Class, Utility or MetaClass), click Shape Display Options, and then, under General Options, select Realization Link.

  2. Glue the control handle Control handle image - yellow diamond for the realization link on a class shape to a connection point Connection point image - blue X on the interface, class, or other element.

Add receptions to a classifier

  1. Double-click the shape representing the classifier you want to add receptions to, and then click the Receptions category.

  2. Click New to add a new reception.

  3. Click the Reception category. Type a name for the reception in the Reception column. In the Signal column, choose the signal to which the classifier, prepared by the reception, reacts, and then choose the other property values you want.

    Note: A signal element must exist in the model for it to be available in the Signal list.

  4. In the Exceptions category, choose the exceptions, if any, that can be generated by the reception.

    Note: An exception element must exist in the model for it to be available in the Signal list.

  5. Add any constraints or tagged values you want, and then click OK until you close the shape's UML Properties dialog box.

Add template parameters to a class

  1. Double-click the shape (Parameterized Class, Class, Utility, Metaclass, or Bound Element) representing the element that you want to add parameters to, and then click Template Parameters.

  2. Click New to add a new parameter.

  3. In the Template parameters list:

    • To edit an existing parameter, type a new name in the Template Parameter column.

    • To edit the type, click a Type field, click the arrow, and then select the type from the list.

    • To add documentation, type in the Documentation box.

  4. Click OK to accept the changes and close the UML Class Properties dialog box.

    Tip: You can make any class a parameterized class by adding parameters to a class shape. To hide parameters on any class shape, right-click the shape, click Shape Display Options and then, under Suppress, select Template Parameters.

Bind template parameters to a class

  1. Drag a Bound Element shape from the UML Static Structure stencil onto the drawing page near the Parameterized Class shape with parameters you want to bind.

  2. Drag a Binding shape onto the drawing page and glue the endpoint without an arrowhead to a connection point Connection point image - blue X on the bound element.

  3. Glue the Binding endpoint with an arrowhead to a connection point on the Parameterized Class shape.

  4. Double-click the Binding shape, and then click Bound Arguments.

  5. Under Bound Arguments, select a parameter to which you want to bind a type (if the parameter has no type specified) or select a value (if the parameter has a type specified). Click Properties, choose the type or type the value you want, and then click OK.

  6. Click OK to close the UML Binding Properties dialog box.

Attributes and operations associated with the parameterized class are passed to the bound element. Unbound parameters (with no specified type) that you have assigned to the class as attribute types or operation return types, are replaced in the bound element by the types you specified in step 5 above.

Create an object as an instance of a class

  1. In a static structure diagram, drag a Class shape onto the drawing page to represent the class you want the object to be an instance of.

  2. Optional  Double-click the Class shape to open the UML Class Properties dialog box. Click Attributes, and then click New to add attributes to the class. Click OK, and then click OK again.

  3. Drag an Object shape onto the drawing page, and then double-click the shape.

  4. In the UML Object Properties dialog box, click Object and type a name for the object. Under Class, select the class you want the object to be an instance of.

  5. Click Attribute Values and select the attribute you want to add an instance value to, and then click Properties. Type a value for the attribute.

  6. Click Attribute Link, add any other property values you want, and then click OK.

  7. Repeat steps 5 and 6 for all the attributes you want to add instance values to, and then click OK.

Delete template parameters from a class

  1. Double-click the shape (Parameterized Class, Class, Utility, Metaclass, or Bound Element) representing the element with parameters you want to delete, and then click Template Parameters.

  2. Select the template parameter you want to delete, click Delete, and then click OK.

Edit template parameters for a class

  1. Double-click the shape (Parameterized Class, Class, Utility, Metaclass, or Bound Element) representing the element with the parameters you want to edit, and then click Template Parameters.

  2. In the Template parameters list, for each parameter you want to edit, click a Type field. Then, click the arrow and select a type from the list.

    Note: You can assign parameters with no type specified to attributes as types or to operations as return types.

  3. In the Template parameters list, for each parameter that you want to edit, type a new name.

  4. In the Documentation box, type the documentation you want.

  5. Click New to add another parameter (and follow steps 3 through 5), or click OK to close the UML Class Properties dialog box.

Hide the attribute and operations sections of a class

  1. Right-click the Class shape, and then click Shape Display Options.

  2. In the UML Shape Display Options dialog box, under Suppress, select Attributes to hide the attributes section, and then select Operations to hide the operations section.

    Tip: To show the attributes and operations sections again, right-click the shape, click Shape Display Options, and then clear Attributes and Operations.

Indicate that classes in a package may be referenced

  1. In a package diagram, drag a Dependency shape onto the drawing page.

  2. Glue the Dependency endpoint without an arrowhead to a connection point on the package that will reference the classes in another package.

  3. Glue the Dependency endpoint with an arrowhead to a connection point Connection point image - blue X on the package that contains the target classes that will be referenced.

  4. Double-click the Dependency shape to open the UML Dependency Properties dialog box.

  5. Under Name, type a name for the dependency. Under Stereotype, choose Import, and then click OK.

Note: Connecting packages with an <<import>> dependency only indicates that classes can be referenced. You still need to set the appropriate visibility for the target classes.

Show the implementation of a type by an implementation class

  1. In a static structure diagram, drag a Class shape onto the drawing page. Double-click the shape.

  2. In the UML Class Properties dialog box, click Class and type a name for the class. Under Stereotype, choose Type, and then click OK.

  3. Drag a second Class shape onto the drawing page. Double-click the shape.

  4. In the UML Class Properties dialog box, click Class and type a name for the class. Under Stereotype, choose Implementation Class, and then click OK.

  5. Right-click the implementation class and click Shape Display Options. In the UML Shape Display Options dialog box, under General Options, select Realization Link, and then click OK.

  6. Drag the control handle Control handle image - yellow diamond on the implementation class shape to create a connector representing a realizes relationship.

  7. Glue the endpoint on the realization connector arrowhead to a connection point Connection point image - blue X on the Class shape representing the type.

No comments:

Post a Comment