Introduction to Rational Rose 2000

Rational Rose 2000
Interaction Diagrams
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
1
Module Objectives
 Define interaction diagrams.
 Describe when and how to create
interaction diagrams.
 Use Rational Rose to create interaction
diagrams.
 Auto generate interaction diagrams.
 Run reports to check mapping.
 Run a RoseScript to check messages.
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
2
Where Are We?
Interaction diagrams are created and refined during the elaboration phase of
this workflow – for architecturally significant use cases.
For remaining use cases, interaction diagrams are created during the
Construction phase. (Guess what this means…)
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
3
Where Are We?
Interaction Diagrams are created and refined during four analysis and design
activities (above) (architectural, use-case analysis, use case design; subsystem
design.)
Input artifacts vary depending on if you are in analysis or design.
Remember, input artifacts are always being updated during previous activity.
We will finish up Use Case Analysis next week….)
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
4
Where are we – continued.
 Architectural and Use Case Analysis
Use case realizations identified during the
requirements workflow may first be created
during architectural analysis or use case analysis
The focus shifts from the big picture to a specific
use case.
Preliminary use case realizations are identified
and modeled as interaction diagrams.
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
5
Where are we – Architectural and Use Case Analysis
 Input artifacts to Architectural and Use Case
Analysis: (some of these…)
 Use case model
 Software architecture document
 Supplementary specifications
 Design model (more with Use Case
Realizations with Interaction Diagrams and
Collaboration Diagrams)
 Glossary
 Design guidelines (platforms, tools, implementing
languages, constraints, etc.)
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
6
Where Are We – continuing….
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
7
Where are we: Use Case Design
 Interaction diagrams, initially defined in use
case analysis, are refined.
 Analysis Classes are replaced with design
subsystems and classes.
 Input Artifacts: (Again, ‘some’ of these…)
 Supplementary specifications;
 Design Subsystems;
 Use Case;
 Interfaces;
 Use Case Realizations;
 Design Classes
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
8
Where are we – Subsystem Design
 Realizations between the subsystem’s interfaces
and contained classes are defined.
 Detailed design of the subsystem may result in
changes to the Use Case realization.
 Input artifacts
 Use case realizations
 Design subsystem with interface definitions
 Design guidelines
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
9
Key Concepts
 Interaction diagrams
 A Use Case’s flow of events describes a sequence of
transactions performed by the system, whereas interaction
diagrams visually capture a single instance of a use case’s
flow of events (a specific path…)
 Two variations: – collaboration and sequence. Both
help to identify objects, classes, interactions, and
responsibilities from a slightly different perspective.
 Collaboration diagrams show how objects associate
with each other. RUP recommends creating these diagrams
during use case analysis. They become too large and
complex during design.
 Sequence diagrams show time-based object interaction.
RUP recommends creating these during use case design.
 Both diagrams help validate the architecture and clarify the
roles of objects in a flow, providing basic input for
determining class responsibilities and interfaces.
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
10
Reports and Scripts
 Reports
 Show unresolved objects - lists all objects
not attached to a class.
 Show unresolved messages - lists all
messages not attached to an operation.
 Script
 A RoseScript that identifies several problems
with messages, including messages without
operations attached to them.
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
11
Part of Deliverable #4:
 Objectives of following Rose diagrams:
 Create collaboration diagrams.
 Constructed sequence diagrams.
 Auto generate diagrams.
 Run Reports to check mapping.
 Run Script to check mapping.
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
12
Add Collaboration Diagram - Setting up the Structure
In the browser, collaboration
diagram added under its
use case realization
Expand the Design Model (in Logical View).
Expand Use Case Realizations Package
Expand the Use Case Realization – Register for Courses
Right click on Register for Courses
Click New, then click Collaboration Diagram. (Note the collaboration symbol)
Type Register for Courses – Basic Flow ‘over’ New Diagram
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
13
Collaboration Diagrams (continued)
In the browser, collaboration
diagram added under its
use case realization
Double click Register for Courses – Basic Flow collaboration diagram symbol.
Collaboration diagram window is now displayed.
Use the format below to name both collaboration and sequence diagrams.
<use case realization name> - <flow type>
Flow types can be basic (main), alternate, and exceptional.
(Remember: You cannot delete from the diagram itself. To delete an unwanted
element, go to the Edit menu; then click Delete from Model.)
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
14
Create a Collaboration Diagram
Actor added to
diagram
Objects added
to diagram
Add Actors:
In the browser, expand the Use Case View again
From the Use Case View, drag the Student actor onto the collaboration diagram
Add objects:
Name objects as you add them to avoid duplication.
From the diagram toolbar, click the Object icon.
Click the diagram to add the object.
Click on the object, then type: :RegisterForCoursesForm
Repeat steps above for :RegistrationController
Size objects if needed to fit text.
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
15
Create a Collaboration diagram
Object assigned
to class
Assign objects to classes
1. In the browser, drag the RegisterForCoursesForm boundary class on to the
RegisterForCoursesForm object in the diagram window. What happens?
2. Repeat step 1 for the remaining object.
Actors
Because actors are external to the system, it is not necessary to assign them
to a class. Remember, we will be using these classes to create a class diagram,
which
represents only the system and not elements external to the system.
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
16
Create a Collaboration diagram
Object assigned
to class
Mapping
We’ve moved directly to mapping objects to
classes. To do so, analysis classes and operations had to be
discovered and modeled. We assume that activity has already
been done.
It’s important to understand that interaction diagrams can be
modeled during analysis using objects and responsibilities.
When the classes and operations are discovered, the designer will
then refine the diagrams and map objects to classes and
responsibilities to operations.
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
17
Create a Collaboration Diagram
Self link
added to object
Link added
between objects
Links - pathways for communications between objects. Can have links back to self
Add object links
1. From the diagram toolbar, click the Object Link icon. Drag your mouse from
Student to the :RegisterForCourseForm class
2. Repeat step 1 to add an object link from :RegisterForCoursesForm to
to RegistrationController.
Add a self link. From the diagram toolbar, click the Link To Self icon.
Click
:RegisterForCoursesForm. What happens?
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
18
Create a Collaboration Diagram (continued)
Operation
added to link
Select collaboration numbering
With numbering active, you must add the messages in order.
1. Make sure collaboration numbering is selected.
On the Tools menu, click Options. Click Diagram.
2. Select the Collaboration numbering check box under Display, then
click OK.
(Do: Tools, Options, Diagrams…
Also see on-like help; “numbering” gives more on hierarchically-numbering
these puppies. )
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
19
Create a Collaboration Diagram ( continued)
Operation
added to link
Add operations to messages
A message link represents communication between two objects that triggers
an event. In a collaboration diagram, it can represent multiple messages.
1. From the diagram toolbar, click the Link Message icon. Click the link between Student
and :RegistrationForCourseForm. The message arrow is added above the link.
2. Right-click the message arrow; then click //register for courses( ) from list of operations
3. Repeat steps 1 and 2 to add a message to :RegisterForCoursesForm’s self-link.
4. Repeat steps 1 and 2 to add a message from :RegisterForCoursesForm to
:RegistrationController.
5. Move arrows and messages as needed to clean up the diagram.
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
20
Create a Collaboration Diagram
Multiple operations
added to link
Add multiple operations
1
Right-click the message arrow, then click //create schedule( ) from
the list of operations.
2
Repeat steps 1 for the remaining messages. Remember, you
must add them in order..
Note: What kind of class is RegisterForCoursesForm? Note the number of
messages from the actor (external) to this class.
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
21
Create Sequence Diagram
Sequence diagram
in browser
Partially completed
sequence diagram
Complete a sequence diagram
1. In the browser, expand the Logical View; Design Model; Use Case Realizations
2. Expand Use Case Realizations-Register for Courses, and Register for Courses
3. Double-click the Register for Courses - Basic Flow sequence diagram.
Note
the sequence diagram symbol.
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
22
Create Sequence Diagram
Object added
to diagram
Add objects
1.
From the diagram toolbar, click the Object icon. Click on the
diagram to add object.
2.
With the object selected, type :RegistrationController. Size
object to fit text.
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
23
Create Sequence Diagram
Object assigned
to class
Operation added
to diagram
Assign objects to classes
In browser, drag the RegistrationController control class on to the RegisterController object
Add operations to messages
1. From the diagram toolbar, click the Object Message icon. Drag your mouse
from RegisterForCoursesForm to RegistrationController. Message arrow added.
2.Right-click the message arrow, then click //is registration open?()
from the list of operations. What happens to the sequence numbering?
3. Move arrows and messages as needed to clean up diagram.
Unlike collaboration diagrams, sequence diagrams can have only one message
between
objects.
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
24
Create Sequence Diagram
Anchor added
to note
Note added
to diagram
Add notes. Notes link one diagram to another diagram.
A linked diagram is indicated by underlined text in the note.
1. From the diagram toolbar, click the Note icon. Click on the diagram.
The note icon is added.
2. With the note selected, type an appropriate note
In the browser, drag the Register for Courses - Basic Flow (Delete Schedule)
sequence diagram on to the note. Notice that the note’s text is now underlined,
indicating the note is now linked to the diagram.
3. Size and position the note
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
25
Create a Sequence Diagram
Anchor added
to note
Note added
to diagram
Anchor notes
1. From the diagram toolbar, click the Anchor Note to Item icon.
Drag your mouse from the note to the “One of these is executed:”note
2.
To also anchor the note to message 6, click the anchor.
3.
Place your cursor in the middle of the anchor, then drag your
mouse to the message arrow.
4.
Double-click on a note. What happens?
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
26
Auto Generate Diagrams
Sequence diagram
generated from
collaboration diagram
Recommend you auto generate sequence diagrams from collaboration diagrams.
Less diagram cleanup.
1. As usual, expand Logical Model; Design Model; Use Case Realizations,
Use Case Realizations – Register for Courses; then expand Register for Courses.
2. Double click Register for Courses – Basic Flow collaboration diagram
3. Press F5 to auto generate its sequence diagram. Compare this sequence
diagram to the one you created previously. What do you notice?
4. Clean up Diagram: Move student to correct position; Resize and move objects
ifIntroduction
needed.
Add notes to diagram, if desired.
to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
27
Check for Unresolved Objects
The Show Unresolved
Objects report indicates
that this object is not
attached to a class
Check for unresolved objects:
1. Expand logical view; design model, UC Realizations, expand
UCR – Register for Courses then expand Register for Courses.
2. Double click Register for Courses – Basic Flow collaboration diagram
3. On the Reports Menu, click Show Unresolved Objects. What happens?
You have an object that is not attached to a class. From the browser, simply
drag the :RegistrationController class onto the object.
4.
Run the report again. Message: “No Unresolved Items Found” is displayed.
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
28
Check for Unresolved Messages
The Show Unresolved
Message report
indicates that this
message is not attached
to an operation
Check for unresolved messages
1. In the browser, expand the Logical View, Design Model, UC Realizations,
Expand Use Case Realizations - Register for Courses; expand Register for Courses.
2. Double-click Register for Courses - Basic Flow sequence diagram.
3. On the Report menu, click Show Unresolved Messages. What happens?
4. You have a message that is not attached to an operation. Right- click the
message arrow, then click //is registration open?( ) from the list of operations.
5. Run the report again. The message “No Unresolved Items Found” is displayed.
Now,
let’s
check
for unresolved messages using a script.
Introduction
to Rational
Rose 2000
v6.5
Copyright © 1999 Rational Software, all rights reserved
29
Run Script to Check Messages
Green start
arrow is pressed
Scripting window
is displayed
RoseScript is a customized version of the Summit BasicScript. It allows you to
automate Rose-specific functions; and, in some cases, perform functions that
are not available through the Rose interface.
Run a Script to Check Messages.
1. Expand Logical View; Design, UC Realizations; Expand UC Realizations – Register for
Courses, then expand Register for Courses.
Double click Register for Courses – Basic Flow sequence diagram.
2. On the Tools menu, click Open Script
3. Open C:\RoseSolutions\Scripts, double click check_messages. Scripting Window opens
4. On the scripting toolbar, click the green start arrow to run script.
Introduction to Rational Rose 2000 v6.5
30
1999 Rational Software, allViewport
rights reserved
5.Copyright
The©BasicScript
is displayed.
Run Script to Check Messages
Unresolved message
detected
You have a message that is not attached to an operation. You can now follow
the same steps as before to assign an operation to the message.
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
31
Next:
Although a little out of sequence, we will create a
class and add its defining characteristics.
 Now that we’ve added our interaction diagrams,
we need to depict the participating classes and
their relationships in class diagrams called view of
participating classes (VOPC).
 These diagrams ensure consistency in use case
implementation across subsystem boundaries.
 Before continuing, let’s take a moment to review
this module’s preferred practices.
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
32
Preferred Practices
 Diagram rules
 Create interaction diagrams for each use case
realization.
 Create at least one main flow diagram.
 Create alternate and exceptional flow diagrams
for significant behavior.
 Name each diagram with the flow type.
 Nest multiple realizations for one use case
under appropriate package.
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
33
Preferred Practices
 Mapping
 Map objects to classes.
 Map messages to operations.
 Map message links to a class relationships.
 Readability
 Add notes and scripts to increase
understanding.
 Move complex alternate flows to separate
diagrams.
 Order objects consistently on similar diagrams.
Introduction to Rational Rose 2000 v6.5
Copyright © 1999 Rational Software, all rights reserved
34