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

Chapter 2: A Tour of Rose

Figure 2.19: Notes

To add a note to a diagram:

1.

Select the Note icon from the toolbar.

2.

Click anywhere inside the diagram to place the note.

3.

Select the Anchor Note to Item button from the toolbar.

4.

Drag and drop from the note to the item.

To remove a note from a diagram, simply select it and press the Delete key.

Working with Packages

A package is a UML construct that is used to group model elements together. You can create a package of use cases, actors, classes, or any other type of model element.

Packages are mainly used to organize the model. In the Use Case view, packages simply group the use cases and actors into more manageable views. In the Logical view, packages are used for two purposes:

They can be used to group the classes and other model elements into logical groupings (i.e., all of the classes that deal with orders, all of the classes that deal with customers, etc.).

They can be used to show the physical deconstruction of the system into architectural layers. For example, one package may hold the user interface elements, while another holds the business logic, and still another holds the database connection classes. The team can then model and analyze the

54

Chapter 2: A Tour of Rose

dependencies between the packages to evaluate the system's architecture.

Packages are a powerful UML tool in this respect. Analyzing the dependencies can show the team how reusable a particular package is, what other packages may need to change if a particular package changes, what the effect would be if a package were to change, and which architectural layers communicate directly with which other architectural layers. A dependency indicates that a class in one package has a relationship to a class in another package.

In general, dependencies between architectural layers should flow from the user interface layer to the business logic layer to the database communications layer to the database itself, as shown in Figure 2.20.

Figure 2.20: Dependencies in architectural layers

Also, as a general guideline, dependencies should not "skip" layers. For example, the user interface should not depend directly upon the database. The team may decide not to follow these guidelines, which is fine, but modeling the architecture through packages is a great way of seeing the implications of these types of architectural decisions. We will discuss this topic further in Chapter 6.

In the Component view, packages are again used to model the different layers, or tiers, of the system architecture, but in this case the packages focus on components rather than classes. In the Deployment view, they can be used to separate different categories of processors or devices.

Packages can be created within packages to further organize the model. This can be especially helpful when modeling very large, complex systems or when modeling applications that communicate with a number of other applications. While it is not necessary to use packages at all, they do help to keep the model organized.

A second use for packages that is specific to Rational Rose is in version control, especially in a multiuser environment. Packages can be used to split the Rose model into separate files, which can then be checked in and out using version control software such as Rational's ClearCase.

To add a package in Rose:

1.

Right−click in the model hierarchy shown in the browser. You can create a package directly under one of the four views (Use Case, Logical, Component, or Deployment) by right−clicking either the Use Case View option, the Logical View option, or the Component View option. Alternatively, you can create a package underneath any existing package by right−clicking the existing package and selecting New → Package.

2.

55

Chapter 2: A Tour of Rose

The new package will appear in the browser. Single−click it to assign it a name.

To remove a package in Rose:

1.

Right−click the package in the browser and select Delete. You will be prompted for confirmation before the package is deleted.

2.

The package will be removed from the model. Please note that any classes, diagrams, or other model elements within the package will be deleted.

Adding Files and URLs to Rose Model Elements

While the Rose model contains a great deal of information about the system, there are other documents, such as the requirements document, vision statement, test scripts, and so on, that are located outside the Rose model. It can be helpful to attach these files to specific elements within the Rose model. Once a Word file, for example, has been attached to the hierarchy in the browser window, you can launch Word and load that file by simply double−clicking the filename in the browser.

To attach a file or URL to a model element:

1.

Right−click the model element in the browser.

2.

Select New → File or New → URL.

3.

Select the appropriate file or URL in the files window.

4.

Once the file or URL has been attached, double−click it in the browser to open it.

5.

To delete the file or URL, right−click it in the browser and select Delete. Note that this operation will simply remove the attachment between the Rose model and the file; it will not delete the file from your system.

Adding and Deleting Diagrams

A Rose model can contain many diagrams, each of which shows a slightly different view of the system. As a collection, these diagrams should give the team a thorough understanding of the system from many different perspectives. The eight types of diagrams supported by Rational Rose are:

Use Case diagrams

Activity diagrams

56