Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Mastering UML with Rational Rose 2002.pdf
Скачиваний:
137
Добавлен:
02.05.2014
Размер:
9.68 Mб
Скачать

Chapter 5: Object Interaction

Select <New> in the Class drop−down list box. Rose will take you to the specification window for the new class.

To ensure all objects have been mapped to classes:

1.

Select Report → Show Unresolved Objects.

2.

Rose will display a list of all objects in the model that have not yet been mapped to a class.

To show only the object name on the diagram:

1.

Right−click the object in the Sequence or Collaboration diagram.

2.

De−select Show Class.

To show both the object and class name on the diagram:

1.

Right−click the object in the Sequence or Collaboration diagram.

2.

Select Show Class.

To show only the class name on the diagram:

1.

If you would rather use only the class name, and not see the object's name at all on the diagram, right−click the object in the Sequence or Collaboration diagram.

2.

Select Open Specification from the shortcut menu.

3.

Delete the object name from the Name field. Rose will display the object using only the class name. Again, the class name is preceded by a colon.

Setting Object Persistence

In Rose, you can set the persistence option for each object in the diagram. Rose provides you with three

173

Chapter 5: Object Interaction

options:

Persistent A persistent object is one that will be saved to a database or to some other form of persistent storage. The implication here is that the object will continue to exist, even after the program has terminated.

Static A static object is one that stays in memory until the program is terminated. It lives beyond the execution of this Sequence diagram, but is not saved to persistent storage. There is, at most, one instance of a static object in memory at any given time.

Transient A transient object is one that stays in memory only for a short time (until the logic in the Sequence diagram has finished, for example).

To set the persistence of an object:

1.

Right−click the object in the Sequence or Collaboration diagram.

2.

Select Open Specification from the shortcut menu.

3.

In the Persistence field, select the appropriate radio button: Persistent, Static, or Transient.

Note If you have set the persistence of the object's class to Persistent, you may set the object's persistence to Persistent, Static, or Transient. If you have set the persistence of the object's class to Transient, you may set the object's persistence to Static or Transient.

Using Multiple Instances of an Object

Rose provides the option of using one icon to represent multiple instances of the same class. Say, for example, that you would like to represent a list of employees on a Sequence or Collaboration diagram. Rather than showing each employee as a separate object, you can use the multiple instances icon to show the employee list. The UML notation for multiple instances looks like this:

To use multiple instances of an object:

1.

Right−click the object in the Sequence or Collaboration diagram.

2.

Select Open Specification from the shortcut menu.

3.

Set the Multiple Instances check box to on or off. Rose will use the appropriate icon (single instance or multiple instances) on a Collaboration diagram and use the single instance icon on a Sequence

174