Essentials of Visual Modeling with UML Module 5...

Post on 09-May-2020

10 views 0 download

transcript

1

IBM Software Group

®

Essentials of Visual Modeling with UML

Module 5: Interaction Diagrams

2

Objectives

Describe dynamic behavior and show how to capture it in a model.Demonstrate how to read and interpret:

A collaboration diagramA sequence diagram

Explain the similarities and differences between collaboration and sequence diagrams.

3

Objects Need to Collaborate

Objects are useless unless they can collaborate to solve a problem.

Each object is responsible for its own behavior and status.No one object can carry out every responsibility on its own.

How do objects interact with each other?They interact through messages.

4

Objects Interact with Messages

A message shows how one object asks another object to perform an operation.

: Car buyer

Message

:RegistrationController :CourseCatalogSystem

getCourseOfferings(forSemester)

5

What Is an Interaction Diagram?

An interaction diagram shows an interaction that consists 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.

Collaboration DiagramsSequence Diagrams

6

Sequence diagramsCollaboration diagramsInteraction diagram comparison

Where Are We?

7

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

8

Example: Sequence Diagram

: Student :RegisterForCoursesForm :RegistrationController : Course Catalog:CourseCatalogSystem

1: create schedule( )

5: display course offerings( )

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

6: display blank schedule( )

4: get course offerings( )

9

Sequence Diagram Contents: Objects

:RegisterForCoursesForm :RegistrationController SWTSU Catalog : CourseCatalogSystem

Anonymous Objects

Lifelines

Named Object

10

:RegisterForCoursesForm :RegistrationController SWTSU Catalog : CourseCatalogSystem

: Student : Course Catalog

Sequence Diagram Contents: Actor

Actor instances

11

Sequence Diagram Contents: Messages

MessageReflexiveMessages

1: create schedule( )

2: get course offerings( )3: get course offerings(for Semester)

4: get course offerings( )

:RegisterForCoursesForm :RegistrationController SWTSU Catalog : CourseCatalogSystem

: Student : Course Catalog

6: display blank schedule( )

5: display course offerings( )

12

1: create schedule( )

2: get course offerings( )

3: get course offerings(for Semester)

4: get course offerings( )

6: display blank schedule( )

:RegisterForCoursesForm :RegistrationController SWTSU Catalog : CourseCatalogSystem

: Student : Course Catalog

Sequence Diagram Contents: Focus of Control

Focus of Control

5: display course offerings( )

13

Sequence diagramsCollaboration diagramsInteraction diagram comparison

Where Are We?

14

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

15

Example: Collaboration Diagram

: Student

: RegisterForCoursesForm

: RegistrationController : CourseCatalogSystem

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

: Course Catalog1: create schedule( )

2: get course offerings( )

3: get course offerings(forSemester)

4: get course offerings( )

16

Collaboration Diagrams Contents: Objects

Objects

: RegisterForCoursesForm

: RegistrationController SWTSU Catalog : CourseCatalogSystem

17

Collaboration Diagram Contents: Actors

: Student : Course Catalog

: RegisterForCoursesForm

: RegistrationController SWTSU Catalog : CourseCatalogSystem

18

Collaboration Diagram Contents: Links and Messages

: Student

: RegisterForCoursesForm

: RegistrationController : CourseCatalogSystem

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

: Course Catalog1: create schedule( )

2: get course offerings( )

3: get course offerings(forSemester)

4: get course offerings( )

19

Sequence diagramsCollaboration diagramsInteraction diagram comparison

Where Are We?

20

Sequence and Collaboration Diagram Similarities

Semantically equivalentCan convert one diagram to the other without losing any information

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

21

Sequence and Collaboration Diagram Differences

Collaboration diagrams

Show relationships in addition to interactionsBetter for visualizing patterns of collaborationBetter for visualizing all of the effects on a given objectEasier to use for brainstorming sessions

Sequence diagrams

Show the explicit sequence of messagesShow focus of controlBetter for visualizing overall flowBetter for real-time specifications and for complex scenarios

22

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?

Review

23

Exercise

Given:A set of objects and their links and messages

Produce:A sequence diagramA collaboration diagram