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

Chapter 6: Classes and Packages

 

Association Class

Links an association class to an association relationship.

 

 

 

 

Package

Adds a new package to the diagram.

 

 

 

 

Dependency or Instantiates

Draws a dependency relationship.

 

 

 

 

Generalization

Draws a generalization relationship.

 

 

 

 

Realize

Draws a realizes relationship.

 

 

 

 

Parameterized Class

Adds a new parameterized class to the diagram.

 

 

 

 

Class Utility

Adds a new class utility to the diagram.

 

 

 

 

Parameterized Class Utility

Adds a new parameterized class utility to the diagram.

 

 

 

 

Instantiated Class

Adds a new instantiated class to the diagram.

 

 

 

 

Instantiated Class Utility

Adds a new instantiated class utility to the diagram.

 

 

 

 

Domain

Adds a new domain to the diagram.

 

 

 

 

Domain Package

Adds a new domain package to the diagram.

 

 

 

 

Server Page

Adds a new server page to the diagram.

 

 

 

 

Client Page

Adds a new client page to the diagram.

 

 

 

 

Form

Adds a new HTML form to the diagram.

 

 

 

 

COM Object

Adds a new COM object to the diagram.

 

 

 

 

Applet

Adds a new applet to the diagram.

 

 

 

Working with Classes

Once you've created your Class diagrams, the next step is to add classes to the model. There are several types of classes you can add: regular classes, parameterized classes, instantiated classes, class utilities, and so on. We'll talk about each of these types of classes in the sections that follow.

We'll also discuss the options Rose provides to add detail to your classes. You can name each class, assign it a stereotype, set its visibility, and set a number of other options. We'll discuss each of these options below.

In this chapter, we'll cover how to view the attributes, operations, and relationships for your classes. In the next few chapters, we'll discuss the details of adding and maintaining attributes, operations, and relationships.

Adding Classes

To begin, let's add a standard class. You can add a class by using the toolbar, the browser, or the menu.

First, you can add a new class to the browser only. In this case, it will be available to add to any diagram, but won't exist on a diagram to start with. Alternatively, you can add a new class to a diagram. If you add a new class to a diagram, it will be automatically added to the browser as well.

To add a new class to a Class diagram:

1.

Select the Class button from the toolbar. The cursor changes to a plus sign (+) when moved to the

209

Chapter 6: Classes and Packages

diagram.

2.

Click anywhere inside the Class diagram. The new class will be named NewClass by default.

3.

Rose will display a list of all existing classes. To place an existing class on the diagram, double−click the existing class in the list, as shown in Figure 6.5. To create a new class, replace the word NewClass with the new class name. Note that the new class has also been automatically added to the browser in the Logical view.

Figure 6.5: Adding a new class

Note If you want to create a new class with the same name as a class in a different package, open the class specification window and enter the class name. You will see a warning telling you that classes with the same name now exist in multiple packages.

OR

1.

Select Tools → Create → Class.

2.

Click anywhere inside the Class diagram to place the new class. The new class will be named NewClass by default.

3.

Rose will display a list of all existing classes. To place an existing class on the diagram, double−click the existing class in the list. To create a new class, replace the word NewClass with the new class name. Note that the new class has automatically been added to the browser in the Logical view.

Note You may also create new parameterized classes, class utilities, parameterized class utilities, instantiated classes, and instantiated class utilities using the Tools → Create menu. A detailed discussion of these types of classes appears later in this chapter.

To add a new class using an Interaction diagram:

1.

210

Chapter 6: Classes and Packages

Open a Sequence or Collaboration diagram.

2.

Right−click an object in the diagram.

3.

Select Open Specification from the shortcut menu.

4.

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

5.

In the class specification window, enter the class name in the Name field.

Note Because Interaction diagrams are in the Use Case view of the browser, new classes created with this method are created in the Use Case view. To move them to the Logical view, drag and drop the classes in the browser.

To add an existing class to a Class diagram:

Drag the class from the browser to the open Class diagram.

OR

1.

Select Query → Add Classes. The Add Classes dialog box will appear, as shown in Figure 6.6.

Figure 6.6: Adding existing classes to a Class diagram

2.

In the Package drop−down list box, select the package that contains the class(es) you want to add to the diagram.

3.

Move the class(es) you want to add from the Classes list box to the Selected Classes list box. To add all the classes, press the All button.

4.

Press OK.

5.

211