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

Appendix: Getting Started with UML

Name the reflexive link.

Tip Pressing F5 on a Collaboration diagram will create the corresponding Sequence diagram.

Building a Class Diagram

A Class diagram is used to show a subset of the classes, interfaces, packages of classes, and relationships in the system. A typical system will have many different Class diagrams.

In Rose, different icons are used to represent different kinds of classes on a Class diagram. For example, Rose contains icons for interfaces, client pages, session EJBs, COM objects, and many other types of classes. Rose also contains icons that distinguish analysis classes from design classes. An analysis class is an implementation−independent view of the system, intended to be an initial sketch of the system design. Design classes are implementation−specific and correlate to the classes that will eventually be created in the source code.

Rose can generate code that will include the class name, attribute types, default values, operation signatures, and class relationships. Developers use the Class diagrams to see the system structure and to know what operations to create for a given class.

Follow these steps to create a new Class diagram:

1.

Right−click a package in the Logical view.

2.

Select New → Class Diagram.

A Class diagram includes a subset of the classes, attributes, operations, relationships, and packages of classes in the system. You can create as many Class diagrams as you need to fully document the system design.

688

Appendix: Getting Started with UML

To add analysis classes to the model:

1.

Select the Boundary, Entity, or Control class button from the toolbar.

2.

Click in the diagram to add the class.

3.

Name the class.

An analysis class is an implementation−independent class. The analysis classes are used to document some of the concepts within the system and to create a conceptual view of the system design.

To add design classes to the model:

1.

Create an additional Class diagram.

2.

Add design classes to the model.

3.

Select the Class button from the toolbar.

4.

Click in the diagram to add the class.

5.

Give the class a name.

A design class is an implementation−specific class within the model. It will correspond to a class in the source code.

689

Appendix: Getting Started with UML

To add interface classes:

1.

Select the Interface button from the toolbar.

2.

Click in the diagram to add the interface.

3.

Name the interface.

An interface is used to expose the public operations of a class without exposing the implementation. An interface contains method signatures, but no implementation.

Follow these steps to add attributes to the classes:

1.

Right−click a class on the diagram.

2.

Select New → Attribute.

3.

Type the attribute name, followed by a colon, and then the attribute's data type (i.e., Address:String).

4.

Optionally enter a default value for the attribute, by following the data type with an equals sign and then the default value (i.e., Address:String = 123 Main St.).

5.

Right−click the attribute in the browser window and select Open Specification.

6.

Set the attribute visibility (public, private, protected).

An attribute is a piece of information associated with a class. All objects in a given class will share the same attributes, but each object may have its own attribute values.

Follow these steps to add operations to the classes:

1.

690

Appendix: Getting Started with UML

Right−click a class on the diagram.

2.

Select New → Operation.

3.

Enter the operation signature, including parameters and a return type. Use the format OpName(Parm1:Parm1DataType, Parm2:Parm2DataType):ReturnType (for example,

AddNumbers(X:Int, Y:Int): Long).

4.

Right−click the operation in the browser window and select Open Specification.

5.

Set the operation visibility (public, private, protected).

An operation is a method within the class. In Rose, you can define the operation name, parameters, visibility, return type, and parameter data types. Certain operations, such as Get() and Set() methods for attributes, can be automatically generated by Rose.

Web Modeling

Thanks to the recent work of people such as Jim Conallen, UML is now being used more and more frequently to model web applications. Rose includes a number of class stereotypes for web modeling, such as client pages, server pages, and HTML forms.

These web classes are placed on a Class diagram and, like traditional classes, can include attributes, operations, and relationships. Using Class diagrams, you can view the web classes and their interrelationships, and also see how the web classes interact with the other classes in the system.

Before following any of these procedures, select Tools → Options. On the Diagram tab, set the default language to Web Modeler.

To add server pages to the model:

1.

Select the Server Page class button from the toolbar.

2.

Click in the diagram to add the class.

3.

691

Appendix: Getting Started with UML

Name the class.

A server page contains logic that runs on the server, and uses server resources such as database connections, security services, or file services.

To add client pages to the model:

1.

Select the Client Page class button from the toolbar.

2.

Click in the diagram to add the class.

3.

Name the class.

A client page contains logic that runs on the client machine.

Follow these steps to add HTML forms to the model:

1.

Select the HTML Form class button from the toolbar.

2.

Click in the diagram to add the class.

3.

Name the class.

An HTML form represents a simple HTML page and the fields contained within that page.

To add applets to the model:

1.

Select the Applet class button from the toolbar.

2.

692

Appendix: Getting Started with UML

Click in the diagram to add the class.

3.

Name the class.

An applet is a small application that is downloaded to the client machine and runs on the client.

To add a web application object to the model:

1.

Select the Web Application class button from the toolbar.

2.

Click in the diagram to add the class.

3.

Name the class.

An application is an object that is used to maintain state information, and is shared among all users of an application.

Follow these steps to add session objects to the model:

1.

Select the Web Session class button from the toolbar.

2.

Click in the diagram to add the class.

3.

Name the class.

A session object is an object that is used to maintain state information, and is specific to a single client and the current session.

693