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

Chapter 2: A Tour of Rose

Working with Rose

Everything you do in Rose relates to a model. In this section, we will discuss how to use models. We will first look at how to create and save Rose models. Then, we will discuss team design considerations by using controlled units, and show you how to publish a Rose model to the Web.

Creating Models

The first step in working with Rose is to create a model. Models can be either created from scratch or made using an existing framework model. A Rose model and all diagrams, objects, and other model elements are saved in a single file with the extension .mdl (model).

To create a model:

1.

Select File → New from the menu, or press the New button on the Standard toolbar.

2.

If the Framework Wizard is installed, then the list of available frameworks will be displayed, as in Figure 2.11. Select the framework you want to use and click OK, or click Cancel to use no framework.

Figure 2.11: Framework Wizard

If you select a framework, Rose will automatically load the default packages, classes, and components that come with that framework. For example, loading the J2EE framework provides default applet, beans, and other classes, as can be seen in Figure 2.12.

45

Chapter 2: A Tour of Rose

Figure 2.12: J2EE foundation

Although they cannot all be seen in the figure, the J2EE framework provides classes and interfaces within each of the packages. Each one has the appropriate attributes and operations, so the team does not need to manually enter them.

There are two benefits to using a framework:

The team does not need to spend unnecessary time modeling elements that already exist. The focus of the modeling effort is on what's unique to a project, not reinventing existing components (although reusing them is fine!).

A framework helps provide consistency across projects. As we mentioned in Chapter 1, a primary benefit of modeling is ensuring consistency between team members or even between entire teams. Using the same framework in different projects ensures that both teams are building from the same foundation.

Rose even gives you the option of creating your own framework. Using this approach, you collect and model the classes and components that form your organization's architectural foundation. Upon this foundation, you can design and build multiple systems.

Saving Models

As with any other application, it is good practice to save the file periodically. Rose is no exception. As mentioned above, the entire model is saved in one file. In addition, you can save the log to a file.

To save a model:

46

Chapter 2: A Tour of Rose

Select File → Save from the menu.

OR

Click the Save button on the Standard toolbar.

To save the log:

1.

Select the log window.

2.

Select File → Save Log As from the menu.

3.

Enter the filename of the log.

OR

1.

Select the log window.

2.

Click the Save button on the Standard toolbar.

3.

Enter the filename of the log.

Exporting and Importing Models

One of the main benefits of the object−oriented paradigm is reuse. Reuse can apply not only to the code but to the models as well. To fully take advantage of reuse, Rose supports exporting and importing models and model elements. You can export a model or a portion of a model and import it into other models.

To export a model:

1.

Select File → Export Model from the menu.

2.

Enter the name of the export file.

To export a package of classes:

1.

Select the package to export from a Class diagram.

2.

Select File → Export <package> from the menu.

3.

47

Chapter 2: A Tour of Rose

Enter the name of the export file.

To export a class:

1.

Select the class to export from a Class diagram.

2.

Select File → Export <class> from the menu.

3.

Enter the name of the export file.

To import a model, package, or class:

1.

Select File → Import Model from the menu.

2.

Select the file to import. Allowable file types are model (.mdl), petal (.ptl), category (.cat), or subsystem (.sub).

Publishing Models to the Web

You can easily publish all or any part of your Rose model to the Web—either to an intranet, the Internet, or a filesystem site—using Rational Rose 2001A or 2002. This way, users who may need to view the model can

do so without having Rose installed and without printing a ream of model documentation. A model published to the Web is shown in Figure 2.13.

Figure 2.13: ATM model on the Web

To publish a model to the Web:

1.

Select Tools → Web Publisher from the menu.

2.

48

Chapter 2: A Tour of Rose

Select the model views and packages to publish from the Web Publisher window, as shown in the Selections field in Figure 2.14.

Figure 2.14: Web Publisher window

3.

In the Level of Detail field, select the desired level of detail. The Documentation Only option includes only high−level information; none of the properties of the model elements are displayed. The Intermediate option displays the properties found on the General tab on model element specifications. The Full option publishes all properties, including those listed on the Detail tab on model element specifications.

4.

Select the notation to use while publishing. Notation will default to the default notation in Rose.

5.

Choose whether or not to publish inherited items.

6.

Choose whether or not to publish properties.

7.

Choose whether or not to publish associations, which are the relationships between model elements. If this box is selected, associations will appear in the browser treeview.

8.

Enter the name of the HTML root filename where the model will be published.

9.

If you want to choose the graphic file format for the diagrams, select the Diagrams button. The Diagram Options window will be displayed, as in Figure 2.15.

49