Rose Tutorial

4 downloads 4246 Views 105KB Size Report
1. Introduction. At the end of this tutorial you should be able to create three diagrams in Rational Rose, the use-case diagram, the sequence diagram, and the ...
Introduction At the end of this tutorial you should be able to create three diagrams in Rational Rose, the use-case diagram, the sequence diagram, and the class diagram. Rational Rose is a program that allows you to build models based on the Unified Modeling Language or more commonly known as the UML. The use-case diagrams allow you to see all the scenarios and how the users act on them. The sequence diagrams allow you to elaborate on each of the use cases by showing example objects and messages that are passed between these objects. Finally, the class diagram describes the types of objects in the program and how they are related to each other. This tutorial assumes that you have an understanding of what each of the diagrams listed above are.

Getting Started To start Rational Rose from your terminal window you must type a series of two commands each time you logon. Once you type them in once you can put it in your ,chsrc folder so it launches the command at logon. The commands are: % setenv LPDEST csl_lw1 % source /usr/local/RationalRose/rs_setup.csh After typing these two commands you will see a menu come up that looks like the following: rsdsu_help On-line documentation main page cqweb start ClearQuest rpweb start RequisitePro viewrup start Rational Unified Process purify added to path purecov added to path quantify added to path rose start Rose soda start SoDA If you look down the list, you will see it says “start Rose” and next to it “rose”. This means to start the program you must type in: % rose

The Main Screen Before we dive into making the three diagrams it is important that we know the important features of the main window. If you look to the far left you will see a side panel as shown in Figure 1.

1

Use Case View

The Use Case View is where you will see all the use cases that you will make. Along with the use cases you will see any actors used in your use case diagrams and the different associations created between the use case and the actor.

Logical View

The Logical View is where you will build your class diagram and your sequence diagrams. Inside here as well you will see the different classes you created and the associations that exist between them.

Figure 1 Beside the side menu you will see a very important toolbox. This toolbox allows you to create many of the different elements that you will use in your diagrams. Figure 2 shows some of the most important elements.

Text Box Note Anchor note to item Create Class Create Interface Unidirectional Association

Create dependency Create Generalization

Figure 2

2

Creating A Use Case Diagram Figure 3 shows a typical use case diagram in Rational Rose. This particular diagram contains four different use cases coming from one single actor. Also four unidirectional associations lead from the actor to each of the use cases.

Use Case

Actor

Figure 3 Use case diagrams are one of the easiest diagrams to create. In a few simple steps you will have a diagram similar to the one in Figure 3. First you must create a use case window this can be done in the following steps. 1. Right click on Use Case View in the side bar 2. Go to new and click Use Case Diagram 3. Type the name of the diagram and hit enter 4. Double click on the name you just typed in. The next step is to create an actor. To create an actor: 1. Right click on Use Case View in the side bar 2. Go to new and this time click Actor 3. Click where you want the actor to be on your screen 4. Type in the name of the actor The next step is to create your use case. This is done in the same fashion as the previous two. 1. Right click on the Use Case View in the side bar 2. Go to new and then Use Case 3. Click where you want the use case to be on your screen and type in the name 3

Now that you know how to create an actor and a use case you must connect the two together by an association. To do this 1. Click on the unidirectional association in the toolbox 2. Draw a line starting from the actor and going to the use case that you want to connect by clicking and dragging. These steps are repeated until you are done creating all your use cases and connecting them properly to your actors, depending on how complicated your drawing is. To rename your use case or actor just double click on the original name and type in the new name.

Creating A Class Diagram Now that we know how to create a simple use case diagram, I am going to teach you a slightly more difficult diagram called the class diagram. When you think of UML diagrams, class diagrams are typically the ones that come to mind. Figure 4 shows a simple example of a class diagram with three classes named VideoStore, Database, and Video.

Class Name

Unidirectional Association Attributes

Operations

Figure 4 When creating a class diagram the first thing that you need to do is create the class diagram window. To do this: 1. Right click on Logical View shown on the side bar 2. Go to new and Class Diagram 3. Type in the name of the class diagram 4. Double click on the name you just typed to bring the window up. 4

Now that you have your window ready, lets create our first class . 1. On the toolbox click the fifth button from the top. Refer to Figure 2. 2. Now just drag where you want your class to be in the window. Now that you have a class lets put some attributes and operations into it. When you double click on the class that you just created a box will pop up like in Figure 5 this is where you will be editing your class. Here you can do many things including changing the name of the class and adding attributes and operations.

Attributes Tab

Operations Tab

Figure 5 Now you should see a box like in Figure 5. To add operations: 1. Click on the tab that reads “operations” 2. Right click anywhere on the white part and select insert 3. Type in the name of the operation and then hit enter If you double click on the operation you created another box will pop up that allows you to customize the operation. Things you can cutomize includes adding parameters and return types. To create an attribute click on the attribute tab and follow the same procedure Once you create your class you can make another class in the same fashion, and connect the two classes with an association. To see how to connect using an association, refer back to the Use Case Diagram section.

5

Creating a Sequence Diagram Now it is time to create a sequence diagram. Figure 6 shows an example of a sequence diagram.

Actor

Object

Association

Lifeline

Before starting to build the sequence diagram brainstorm and think of all the different scenarios that you are going to need to show. Once you have it all planned out it is time to begin creating the diagram. The first thing to be done, as in all the other diagrams, is to create the sequence diagram window. To create the window: 1. 2. 3. 4.

Right click on Logical View shown on the side bar Go to new and then sequence diagram Type in the name of the sequence diagram Double click on the name that you just typed in

You are going to want to create new windows for each sequence diagram that you make. Once you have your window all set the first thing to do is to drag your actor from your use case diagram into the window. To do this: 1. On the side bar under Use Case View you should see the actor you created with your use case diagram. 2. Click on it and drag it into your sequence diagram window

6

Now it is time to add your objects to your sequence diagram. To do this: 1. On the side bar under Logical View you should see all the classes you created 2. Click on them one at a time and drag them onto your sequence diagram. 3. Order the objects in the order in which methods will be called on them. Now we must associate the actor with the first class. To do this: 1. Click on create association on the toolbox 2. Below your actor you should see the tip of a lifeline starting. Drag from here to the class you want to associate with. 3. Now you must label the association with the proper label. 4. Right click on the association you created and you will see all the different methods that could be called from the association between those two objects. Choose one of them. Now start from just below the end point of the association you just created and repeat the process, connecting the next class with this one. Continue this until your sequence diagram is complete.

7