rationalrose guide

28
PRACTICAL UML Introductory Course for System Designers UML Workshop  August 2008 Department of Software Engineering College of Information Technology University of Tenaga Nasional KM 7, Jalan Kajang-Puchong 43009, Kajang Selangor Volume 1

Upload: muhamad-faiz-sulaiman

Post on 14-Apr-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 1/28

PRACTICAL UMLIntroductory Course for System Designers

UML Workshop – August 2008

Department of Software Engineering College of Information Technology University of Tenaga NasionalKM 7, Jalan Kajang-Puchong 

43009, Kajang Selangor

Volume

1

Page 2: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 2/28

 

Table of Contents

 Introduction ............................................................................................................ 1 General Guide: Modeling UML Using Rational Rose .............................. 1 Problem Statement: Course Registration System .................................. 4 Use Case Diagram with Rational Rose ......................................................... 5 

Use case notations ........................................ ............................................. ................... 5 Use Case Diagram: Course Registration System ........................................... ... 6 

Use Case Documentation ................................................................................... 7 Class Diagram with Rational Rose ................................................................ 8 

Attributes and Operations .................................................................................................. 10 

Relationship .............................................................................................................................. 12 

Class Diagram: Course Registration System .................................................. 12 Interaction Diagram with Rational Rose ................................................. 16 

Sequences Diagram: Course Registration System ....................................... 20 State Transition and Activity Diagram with Rational Rose ............. 21 

State transition diagram ........................................... .............................................. 21 Activity Diagram......................................................................................................... 25 

Acknowledgements .......................................................................................... 26 

Page 3: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 3/28

U M L W O R K S H O P

1

Introductionearning UML will be ineffective if explanation is based solely on theory, with no implementationto any case study. With this exercise, case study is given for participants to work with. RationalRose will be used as a modeling tool to create UML diagrams. The structure of this tutorial is asfollows:

General Guide: Modeling UML Using Rational Rose: This section presents basic guidelines on how todraw UML diagrams using Rational Rose.

UML Diagrams of Course Registration System:  This section provides specific guidelines on how todraw UML diagrams for Course Registration System.

General Guide: Modeling UML Using

Rational Rose The goal of this exercise is to be able to use Rational Rose to make models. Rational Rose is a

CASE tool (Computer Aided Software Engineering), that can be used for modeling using UML

diagrams. Modeling is the task of creating a description of a system, to make it possible to

understand and communicate how it works. There are several other features in Rational Rose, such

as source code generation from models and generation of models from source code. However, inthis exercise we will only cover the use of Rational Rose in drawing UML diagrams. Before you start

using Rational Rose, be sure that you are familiar with the Unified Modeling Language (UML).

L

Page 4: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 4/28

U M L W O R K S H O P

2

1.  Open Rational Rose. If you wish to draw diagrams for analysis and documentation purpose,

click Cancel when you see screen shown in Figure 2 .

Figure 1

2.   When Rational Rose is started its main window becomes visible. In the left part of it, there

is a tree structure which gives a structured view on the currently opened model (refer

Figure 2).

Figure 2

Designelements

 Treestructure

Page 5: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 5/28

U M L W O R K S H O P

3

Different views in the tree structure are meant to describe different aspects of the modeled

system:

  Use Case View , shows the functionality of the system as perceived by external actors.

  Logical View , shows the internal structure and behavior in the system. This shows

how the functionality is designed.

  Component View , shows how the system is organized into different code

components (such as source code files) and the dependencies between those

components.

  Deployment View , shows the deployment of the system in the physical world, with

nodes such as computers and other devices and the connections between them.

 The diagrams and modeling elements you create for a model are located in some of these

 views. In this exercise, we will only use the Use Case View and the Logical  View.

3.   To create a new diagram in a view, right-click on the view folder, select New  in the

menu that pops up, and finally select the diagram type you want to create. The new 

diagram is added to the tree structure and you can type in a name for it. As you might have

noticed, there are already a few diagrams called Main in the tree structure.

4.  Double clicking on a diagram in the tree structure opens it in the right part of the Rational

Rose main window, where it can be edited. Design elements, such as actors, classes and

relations, can be added to diagrams by selecting them from the bar in the middle of the

main window and clicking where they are to be placed in the diagram.

5.  Properties of the design elements can be edited by double clicking the element to bring up

a dialog window where changes can be made.

6. 

In Rational Rose, design elements are not only parts of diagrams. When a design element isadded to a diagram, it is automatically added to the tree structure. The tree structure can be

thought of as a repository, where all design elements are available, while each diagram

displays a subset of the elements.

7.   You can add an existing design element from the tree structure to a diagram by drag-

and-drop.

8.   This means that each design element can be present in several diagrams, and changing the

properties of it at one place, modifies it on all the diagrams.

9.  Removing a design element from a diagram is done by clicking it followed by pressing 

the Del key. However, this does not remove the element from the tree structure or form

other diagrams where it is visible.10.  To remove a design element from the tree structure, right click on it and select Delete

from the menu that pops up. This will affect all diagrams containing the design element.

Page 6: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 6/28

U M L W O R K S H O P

4

Note

Microsoft Visio, Software Architect, Borland Together Control Center are examples of other modeling tools that can be used to draw UML diagrams.

Problem Statement: Course Registration

System

 The requirements definition described below will be used throughout the lab session.

 At the beginning of each semester, students may request a course catalogue containing a list of 

course and course offerings for the semester. Information about each course and course offering,

such as lecturer, department, prerequisites, time and location will be included to help students

make informed decisions.

 The new system will allow students to select four course offerings for the coming semester. In

addition, each student will indicate two alternative choices in case a course offering becomes filled

or cancelled. No course offering will have more than ten students. No course offering will havefewer than three students. A course offering with few than three students will have to be

cancelled. Once the registration process is completed for a student, the registration system sends

information to the billing system so the student can be billed for the semester.

Lecturers must be able to access the on-line system to indicate which course offerings they will be

teaching. They will also need to see which students signed up for their course offerings.

For each semester, there is a period of time that students can change their schedule. Students

must be able to access the system during this time to add or drop courses.

Page 7: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 7/28

U M L W O R K S H O P

5

Use Case Diagram with Rational Rose1.   As briefly mentioned before, a use case diagram is drawn under Use Case View.

2. 

 To begin drawing, expand the Use Case View folder (by clicking the sign next to it) inthe browser pane ( Figure 3 ).

3.   Then, double click Main to display a new window titled Use Case Diagram: Use Case View 

/ Main. This is where you draw your use case diagram.

Figure 3 

Use case notations

1.   Three main notations used in use case diagram are:  Use case (oval shape), Actor (sticky figure) and Relationship (arrow) as indicated in Figure 4. 

Figure 4

2.   To draw a use case, click on the use case notation in the drawing toolbar, and then click onthe appropriate diagram pane. Accordingly, the newly created use case name and icon willappear in the browser pane.

3.   To delete an actor or a use case, right click on the actor or use case name in the browserpane and choose Delete (Figure 5).

Page 8: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 8/28

U M L W O R K S H O P

6

Figure 5

Use Case Diagram: Course Registration System

 This is an example of use case diagram for the Course Registration System mentioned before

(refer Figure 6).

Figure 6

Page 9: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 9/28

U M L W O R K S H O P

7

Note

Designing, and afterwards, implementing the whole of the Course Registration problemstatement is very delicate and time consuming. The scope is very large, and hence isbeyond the coverage of our lab session. Therefore, from this session onwards, we will befocusing on designing and implementing only a portion of the whole system. For thispurpose, we decide to design and implement the Register for courses use case thatinteracts with Student and Billing System. .

Use Case Documentation

1.   To associate documentation to a use case, click the use case on the diagram pane and right-click on the use case, choose open specification and type the documentation in the Documentationtext area (Figure 7).

Figure 7

2.   As for the flow of events, you can use external word processor application, such as Microsoft Word to type it.

3.   To associate this external file to a particular use case, on the specification dialog box, click onthe Files tab and then right click to view the pop up menu. Choose Insert File (Figure 8) andbrowse to the directory where the Word file is saved. Then, click the OK button.

4.   As you may notice from Figure 8, you can also have the flow of events stored in a URL (webpage).

Page 10: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 10/28

U M L W O R K S H O P

8

Figure 8

Class Diagram with Rational Rose

1.  Class diagram is drawn under Logical View.2.   To begin drawing, expand the Logical View folder and double click on Main.3.   Alternatively, you can right-click on the Logical View folder in the browser pane, choose

New Class Diagram (Figure 9). Notice that the contents of the drawing toolbar will

change accordingly.4.  Select the class icon from the toolbar (Figure 10) and place it on the drawing pane.

Figure 9

Page 11: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 11/28

U M L W O R K S H O P

9

Figure 10

Note

 A class is a collection of objects with the same structure and behavior. There are threecommon types (known as stereotypes) of classes. Note that other types are also possible. The common types are:• Entity class: class that models information and associated behavior that is generally long-lived and independent of its surroundings• Boundary class: class that models communication between the system’s surroundingsand its inner workings• Control class: class that models control behavior specific to one or more use cases.

5.   To associate a stereotype to a class (whether boundary, entity or control stereotype), rightclick on a class and open its specification.

6.  On the General tab, go to the Stereotype text field and choose the appropriate stereotypefrom the drop down combo box (Figure 11).

Page 12: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 12/28

U M L W O R K S H O P

10

Figure 11

7.  In order to find candidates for entity, boundary and control classes, each use casedocumentation and flow of events will have to be examined in detail. Initially, there will beonly one control class for each use case.

Attributes and Operations

1.   To create an attribute or an operation for a class, right click on the class and on thepop-up menu that appears, click on either New Attribute or New Operation (dependson whether you want to create new attribute or new operation) as shown in Figure 12 .

2.   The result of adding attribute and operations to a class in shown in Figure 13. 

Page 13: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 13/28

U M L W O R K S H O P

11

Figure 12 

Figure 13 

3.   To determine the type of an attribute, double click on a class to open its specification,and then click on the Attributes tab.

4.  Double click on the attribute’s name in the list and a specification for attribute as shownin Figure 14 will be opened. You can specify the type from the Type combo box.

Figure 14 

Page 14: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 14/28

U M L W O R K S H O P

12

Relationship

1.   To create a relationship in Rational Rose, first click on the appropriate arrow on thetoolbar.

2.   Then, drag your mouse from one class to the other that you want to relate with andclick on the other class. You can also specify the multiplicity of the relationship by right clicking on the relationship line/arrow as shown in Figure 15 below.

Figure 15

Class Diagram: Course Registration System

 Table 1 next page shows the list of classes identified for the Register for courses use case stated in theprevious lesson. Based on the information available from the table, draw all the classes using RationalRose Enterprise application. Make sure that you use proper technique for labeling  the classes’

stereotypes, attributes and operations.

Page 15: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 15/28

U M L W O R K S H O P

13

 Table 1

Class Name /Type   Attribute (Type)  Operation 

Student /Entity StudentID (String) -

ScheduleForm/ Boundary - displaySchedule

CreateScheduleForm /Boundary - enterPrimaryCourseenterSecondaryCoursedisplayFormsubmitFormprintSchedule

LoginForm / Boundary - enterID verifyID

RegistrationForm /Boundary - selectSemesterselectCreateScheduleselectReviewScheduleselectChangeSchedule

 AddDropCourseForm/Boundary 

- chooseSubjectdisplayFormselectAddDropsubmitAddDropcheckDueDate

StudentInformation /Entity studentName (String)studentID (String)courseTaken

checkPrerequisitecreateSchedulesubstitudeAlternativeCourse

checkStudentLoading CourseOffering /Entity maxStudent (Integer)

minStudent (Integer)currentStudent(Integer)

addStudentdeleteStudentcheckCourseAvailability 

RegistrationManager /Control - registerStudentderegisterStudentdisplayStatus

Lecturer /Entity staffID (String)staffName (String)

Course /Entity courseName (String)

courseNumber(Integer)creditHour (Integer)

createCourseName

generateCourseNumber

BillingSystem /Control - -

Page 16: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 16/28

U M L W O R K S H O P

14

 Table 2 shows some of the relationship between the classes that you have drawn before.Include these relationships in your class diagram. Figure 16 shows an example of associationand Figure 17 shows an example of navigation.

 Table 2

Class Name Class Name Relationship

Lecturer Course Association. A lecturer can teach oneor more courses, maximum of threecourses.

Course CourseOffering Association. A course can only haveone course offering 

RegistrationForm ScheduleForm, AddDropCourseForm,CreateScheduleForm

Navigation from RegistrationForm

Student LoginForm Association

LoginForm RegistrationForm Navigation towards RegistrationForm

ScheduleForm StudentInformation Association

CreateScheduleForm CourseOffering Navigation towards CourseOffering 

StudentInformation RegistrationManager,ScheduleForm

 Association

RegistrationManager BillingSystem Association

RegistrationManager Student Navigation towards Student

Figure 16

Page 17: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 17/28

U M L W O R K S H O P

15

Figure 17

 To create association as shown in Figure 17, right-click on the arrow that link between classes andchoose Navigable (refer Figure 18).

Figure 18

Page 18: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 18/28

U M L W O R K S H O P

16

Interaction Diagram with Rational Rose

1.  Interaction diagrams (which consist of sequence and collaboration diagrams) are alsodrawn under Logical View.

2.   To begin drawing, right-click on the Logical View folder in the browser pane, chooseNew→ Sequence Diagram (Figure 19).

Figure 19

3.   Alternatively, you can also choose Browse→ Interaction Diagram from the menu(Figure 20). Select Logical View and click OK.

Figure 20

Page 19: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 19/28

U M L W O R K S H O P

17

4.  Give a name to your diagram and indicate whether it is a sequence or collaboration diagram(Figure 21).

Figure 21

5. 

Sequence diagrams and interaction diagrams for a particular use case provide the sameinformation. Therefore, once you have drawn a sequence diagram, Rational Rose canautomatically generate the associated collaboration diagram for you and vice~versa. However,modifications are normally required to improve the auto-generated diagrams.

6.  Before you can begin drawing a sequence diagram, you have to have the class diagramcontaining classes and their relationship with one another, which was drawn before. If you donot have it, you have to redraw the class diagram first.

7.   To begin drawing, click the object icon in the toolbar and place it in the drawing pane (Figure22).

8.   Then, double click the object just created to open its specification. Select the appropriate classthat the object belongs to from the Class combo box (Figure 23).

Figure 22

Page 20: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 20/28

U M L W O R K S H O P

18

Figure 23

9.   Alternatively, you can also drag those classes from the browser pane. If you cannot see the list

of classes in the browser pane, expand the Logical View folder.10. Press CTRL-D if you wish to delete any classes or Message.11.  You can switch between sequence and collaboration diagrams by pressing F5 key or by 

choosing Browse→Create Collaboration Diagram from the menu (Figure 24). Make sure thatyour sequence diagram window is the active window before you perform this task.

Page 21: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 21/28

U M L W O R K S H O P

19

Figure 24

12. Sometimes, new operation for a particular class, which was not included in the class diagrambefore, is discovered while you are drawing the interaction diagrams. Addition of this new operation is possible as shown by Figure 25. 

Figure 25

Page 22: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 22/28

U M L W O R K S H O P

20

Sequences Diagram: Course Registration

System

Figure 26 shows example of sequence diagram for Registering Course.

Figure 26

Page 23: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 23/28

U M L W O R K S H O P

21

State Transition and Activity Diagram

with Rational Rose

 A state transition diagram is used to show the life history of a given class, the events that causea transition from the state and the actions that result from a state change. The state of anobject is one of the possible conditions in which an object may exist. State transition diagramsare created for classes with significant dynamic behavior, i.e. not for all classes.

State transition diagram

1.  To draw a state diagram, right click on a class in the class diagram (drawn previously) that you want to associate the state diagram with.

2.  Then right-click and choose -> New Statechart diagram (Figure 27). A new diagram pane willbe displayed. This is where you draw your state diagram. Notice that the contents of thedrawing toolbar change accordingly.

3.  To begin drawing, click on the appropriate icons from the drawing toolbar and place it into thediagram pane. An example of a state transition diagram for CourseOffering class is shown in(Figure 28).

Figure 27

Page 24: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 24/28

U M L W O R K S H O P

22

Figure 28

4.  You should label each state transition with the name of at least one event that causes the statetransition. You do not have to use unique labels for state transitions because the same eventcan cause a transition to many different states or activities.

5.  Transitions are labeled with the following syntax:

event (arguments) [condition] / action ^ target.sendEvent(arguments)

6.  Only one event is allowed per transition, and one action per event.7.  Events, conditions and actions must be added by editing the label or through the State

 Transition Specification, refer to Figure 29 to see labels under General Tab. Figure 30 showslabels available under Detail tab.

Page 25: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 25/28

U M L W O R K S H O P

23

Figure 29

Figure 30

Page 26: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 26/28

U M L W O R K S H O P

24

8.   You can place guard conditions on transitions to or from almost any element on a statechartdiagram or activity diagram. A guard condition usually represents some sort of true/falsecondition.

9.   To place a guard condition on a transition, place a transition between two elements on the

diagram.10.  Double-click on the transition to display the State Transition Specification.11.  Click the Detail tab. Type a true/false value in the Guard Condition field (refer Figure 31).

Notice how the guard condition is displayed in brackets next to the transition on thediagram.

Figure 31 

Page 27: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 27/28

U M L W O R K S H O P

25

Activity Diagram

In contrast to a state transition diagram, an activity diagram is used to model the flow of 

procedures of activities in a class. When conditions are used to decide which activity to invoke,the activity diagram uses a decision node to represent the choices.

1.   To begin drawing an activity diagram, repeat the same steps used to draw statetransition diagram. However, after right-click on the class, choose New -> Activity Diagram.

2.   As what we have seen before (Statechart lesson), you may repeat the same steps toplace guard conditions on transitions.

3.   An example of an activity diagram for class RegistrationForm is shown in Figure 32. 

Figure 32

Guardcondition

Page 28: Rationalrose Guide

7/29/2019 Rationalrose Guide

http://slidepdf.com/reader/full/rationalrose-guide 28/28

U M L W O R K S H O P

Acknowledgements

 This manual is produced by accumulating information from various resources as presented below:

[1]  http://metalab.uniten.edu.my/~hazleen/CMPB225/

[2]  http://metalab.uniten.edu.my/~faridah/oose.htm

[3]  http://www.math-cs.gordon.edu/courses/cs211/

[4]  http://www.ida.liu.se/~TDDB62/uml.en.shtml

[5]  http://dn.codegear.com/article/31863 

[6]  Rational Rose Help function