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

Chapter 10: Component View

There are additional Component icons that are used for runtime components. Runtime components include executable files, DLL files, and tasks.

Task Specification and Body These icons represent packages that have independent threads of control. An executable file is commonly represented as a task specification with a .exe extension.

Database This icon represents a database, which may contain one or more schemas. On a Component diagram, a database is shown with the following icon:

In addition to modeling the component itself, you can model the relationship between a component and its interface. On a Component diagram, a component with its interface would look like this:

Component Diagrams

A Component diagram is a UML diagram that displays the components in the system and the dependencies between them. Figure 10.1 is an example of a Component diagram.

362

Chapter 10: Component View

Figure 10.1: Component diagram

With this diagram, the staff responsible for compiling and deploying the system will know which code libraries exist and which executable files will be created when the code is compiled. Developers will know which code libraries exist and what the relationships are between them. The component dependencies will let those who are responsible for compiling know in which order the components need to be compiled.

In the example in Figure 10.1, there are four components. The FlightServer component realizes the classes Customer, Flight, and FlightList, all of which are on the server. The Flight component realizes the server pages and client pages that are responsible for searching for flights and displaying flight information. The Credit component realizes the CreditForm class, and the Reservation component realizes the ReserveSeat and ConfirmationForm server and client pages.

Creating Component Diagrams

In Rose, you can create Component diagrams in the Component view. Once the diagrams are created, you can either create components directly on the diagram or drag existing components from the browser to the diagram.

In the browser, Component diagrams are displayed with the following icon:

To create a Component diagram in the Component view:

1.

In the browser, right−click the package that will contain the Component diagram.

2.

Select New → Component Diagram from the pop−up menu.

3.

Enter the name of the new Component diagram.

OR

1.

Select Browse → Component Diagram. This displays the Select Component Diagram window.

2.

363

Chapter 10: Component View

Select the desired package.

3.

Select <New> from the Component Diagram box and click OK.

4.

Enter the name of the new Component Diagram and click OK.

To delete a Component diagram:

1.

In the browser, right−click the Component diagram.

2.

Select Delete from the pop−up menu.

OR

1.

Select Browse → Component Diagram. This displays the Select Component Diagram window.

2.

Select the desired package.

3.

Select the component to delete.

4.

Click the Delete button.

Adding Components

Once you've created the Component diagram, the next step is to add components. You begin by creating a generic component and then assigning the appropriate stereotype to it. In the Component Diagram toolbar, buttons are available for all the different types of icons listed in the earlier section titled "Types of Components."

You can add documentation to the components as well. Documentation may include a description of the purpose of the component or a description of the class(es) in the component.

Like classes, components can be packaged together to organize them. Typically, you create one Component view package for each Logical view package. For example, if a Logical view package called Orders contains classes called Order, OrderItem, and OrderForm, the corresponding Component view package would contain the components that hold the Order, OrderItem, and OrderForm classes.

To add a component:

1.

Select Component from the toolbox toolbar.

2.

364

Chapter 10: Component View

Click on the diagram where the new component will be placed.

3.

Enter a name for the new component.

OR

1.

Select Tools → Create → Component.

2.

Click on the diagram where the new component will be placed.

3.

Enter a name for the new component.

OR

1.

In the browser, right−click the package to contain the component.

2.

Select New → Component from the pop−up menu.

3.

Enter a name for the new component.

To add documentation to a component:

1.

Right−click the desired component.

2.

Select Open Specification from the pop−up menu. This opens the component's specification window.

3.

Select the General tab.

4.

Enter documentation in the Documentation field.

OR

1.

Double−click the desired component. This opens the component's specification window.

2.

Select the General tab.

3.

Enter documentation in the Documentation field.

365

Chapter 10: Component View

OR

1.

Select the desired component.

2.

Select Browse Specification. This opens the component's specification window.

3.

Select the General tab.

4.

Enter documentation in the Documentation field.

OR

1.

Select the desired component.

2.

Enter documentation in the documentation window.

To delete a component from the diagram only:

1.

Select the component in the diagram.

2.

Press Delete.

Note The component has been removed from the diagram, but still exists in the browser and on other Component diagrams.

To delete a component from the model:

1.

Select the component on a Component diagram.

2.

Select Edit Delete from Model, or press Ctrl+D.

OR

1.

Right−click the component in the browser.

2.

Select Delete from the shortcut menu.

Note Rose will remove the component from all Component diagrams, as well as from the browser.

366