Вы находитесь на странице: 1из 22

Principles of Object Technology

Module 5: Interaction Diagrams

Objectives: Interaction Diagrams


Learn how to create interaction diagrams to model use-case behavior. Understand the similarities and differences between sequence and collaboration diagrams.

<Course Title and Version Number> Copyright 2000 Rational Software, all rights reserved

Where Are We?


Review: Object Interactions Sequence diagrams Collaboration diagrams Interaction diagram comparison

<Course Title and Version Number> Copyright 2000 Rational Software, all rights reserved

So Where Are We?


Discovered boundary, control, and entity classes Assigned responsibilities to each class Determined how to use these classes to realize use-case scenarios

<Course Title and Version Number> Copyright 2000 Rational Software, all rights reserved

What Is an Interaction Diagram?


An interaction diagram shows an interaction, consisting of a set of objects and their relationships, including the messages that may be dispatched among them. It models the dynamic aspects of a system.

Sequence Diagrams

Collaboration Diagrams

<Course Title and Version Number> Copyright 2000 Rational Software, all rights reserved

Where Are We?


Review: Object Interactions Sequence diagrams Collaboration diagrams Interaction diagram comparison

<Course Title and Version Number> Copyright 2000 Rational Software, all rights reserved

What Is a Sequence Diagram?


A sequence diagram is an interaction diagram that emphasizes the time ordering of messages. The diagram shows
The objects participating in the interaction. The sequence of messages exchanged.

Sequence Diagrams
<Course Title and Version Number> Copyright 2000 Rational Software, all rights reserved

Example: Sequence Diagram


RegisterForCoursesForm

: Student

: : RegistrationController CourseCatalogSystem

: Course Catalog

1: // create schedule( ) 2: // get course offerings( ) 3: // get course offerings(forSemester) 4: // get course offerings( ) 5: // display course offerings( )

6: // display blank schedule( )

<Course Title and Version Number> Copyright 2000 Rational Software, all rights reserved

Sequence Diagram Contents: Objects


: RegisterForCoursesForm : RegistrationController SWTSU Catalog : CourseCatalogSystem

Unnamed Objects

Named Object Lifelines

<Course Title and Version Number> Copyright 2000 Rational Software, all rights reserved

Sequence Diagram Contents: Actor


:
: Student RegisterForCoursesForm

:
RegistrationController

SWTSU Catalog : CourseCatalogSystem

: Course Catalog

Actors

<Course Title and Version Number> Copyright 2000 Rational Software, all rights reserved

10

Sequence Diagram Contents: Messages


:
: Student RegisterForCoursesForm

:
RegistrationController

SWTSU Catalog : CourseCatalogSystem

: Course Catalog

1: // create schedule( ) 2: // get course offerings( ) 3: // get course offerings(forSemester) 4: // get course offerings( ) 5: / /display course offerings( )

Reflexive Messages

Message
6: // display blank schedule( )

<Course Title and Version Number> Copyright 2000 Rational Software, all rights reserved

11

Sequence Diagram Contents: Focus of Control


:
: Student RegisterForCoursesForm

:
RegistrationController

SWTSU Catalog : CourseCatalogSystem

: Course Catalog

1: // create schedule( ) 2: // get course offerings( ) 3: // get course offerings(forSemester) 4: // get course offerings( ) 5: / /display course offerings( )

6: // display blank schedule( )

Focus of Control

<Course Title and Version Number> Copyright 2000 Rational Software, all rights reserved

12

Where Are We?


Review: Object Interactions Sequence diagrams Collaboration diagrams Interaction diagram comparison

<Course Title and Version Number> Copyright 2000 Rational Software, all rights reserved

13

What Is a Collaboration Diagram?


A collaboration diagram emphasizes the organization of the objects that participate in an interaction. The collaboration diagram shows
The objects participating in the interaction. Links between the objects. Messages passed between the objects.

Collaboration Diagrams
<Course Title and Version Number> Copyright 2000 Rational Software, all rights reserved

14

Example: Collaboration Diagram


5: // display course offerings( ) 6: // display blank schedule( )

1: // create schedule( )

: Student

: RegisterForCoursesForm : Course Catalog

2: // get course offerings( ) 4: // get course offerings( ) 3: // get course offerings(forSemester)

: RegistrationController

: CourseCatalogSystem

<Course Title and Version Number> Copyright 2000 Rational Software, all rights reserved

15

Collaboration Diagrams Contents: Objects

: RegisterForCoursesForm

Objects

: RegistrationController

SWTSU Catalog : CourseCatalogSystem

<Course Title and Version Number> Copyright 2000 Rational Software, all rights reserved

16

Collaboration Diagram Contents: Actors

: Student

: RegisterForCoursesForm

: Course Catalog

: RegistrationController

SWTSU Catalog : CourseCatalogSystem

<Course Title and Version Number> Copyright 2000 Rational Software, all rights reserved

17

Collaboration Diagram Contents: Links and Messages


5: // display course offerings( ) 6: // display blank schedule( )

1: // create schedule( )

: Student

: RegisterForCoursesForm : Course Catalog

2: // get course offerings( ) 4: // get course offerings( ) 3: // get course offerings(forSemester)

: RegistrationController

: CourseCatalogSystem

<Course Title and Version Number> Copyright 2000 Rational Software, all rights reserved

18

Where Are We?


Review: Object Interactions Sequence diagrams Collaboration diagrams Interaction diagram comparison

<Course Title and Version Number> Copyright 2000 Rational Software, all rights reserved

19

Sequence and Collaboration Diagram Similarities


Semantically equivalent
Can convert one diagram to the other without losing any information

Model the dynamic aspects of a system Model a use-case scenario

<Course Title and Version Number> Copyright 2000 Rational Software, all rights reserved

20

Sequence and Collaboration Diagram Differences


Collaboration diagrams
Show relationships in addition to interactions Better for visualizing patterns of collaboration Better for visualizing all of the effects on a given object Easier to use for brainstorming sessions

Sequence diagrams
Show the explicit sequence of messages Better for visualizing overall flow Better for real-time specifications and for complex scenarios

<Course Title and Version Number> Copyright 2000 Rational Software, all rights reserved

21

Checkpoints
What is the purpose of an interaction diagram? What is a sequence diagram? A collaboration diagram? What are the similarities between sequence and collaboration diagrams? What are the differences between sequence and collaboration diagrams?

<Course Title and Version Number> Copyright 2000 Rational Software, all rights reserved

22

Вам также может понравиться