essentials of visual modeling with uml module 5...

23
1 IBM Software Group ® Essentials of Visual Modeling with UML Module 5: Interaction Diagrams

Upload: others

Post on 09-May-2020

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Essentials of Visual Modeling with UML Module 5 ...read.pudn.com/downloads91/ebook/348025/DEV275_05_Interaction.pdf · What Is an Interaction Diagram? An interaction diagram shows

1

IBM Software Group

®

Essentials of Visual Modeling with UML

Module 5: Interaction Diagrams

Page 2: Essentials of Visual Modeling with UML Module 5 ...read.pudn.com/downloads91/ebook/348025/DEV275_05_Interaction.pdf · What Is an Interaction Diagram? An interaction diagram shows

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.

Page 3: Essentials of Visual Modeling with UML Module 5 ...read.pudn.com/downloads91/ebook/348025/DEV275_05_Interaction.pdf · What Is an Interaction Diagram? An interaction diagram shows

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.

Page 4: Essentials of Visual Modeling with UML Module 5 ...read.pudn.com/downloads91/ebook/348025/DEV275_05_Interaction.pdf · What Is an Interaction Diagram? An interaction diagram shows

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)

Page 5: Essentials of Visual Modeling with UML Module 5 ...read.pudn.com/downloads91/ebook/348025/DEV275_05_Interaction.pdf · What Is an Interaction Diagram? An interaction diagram shows

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

Page 6: Essentials of Visual Modeling with UML Module 5 ...read.pudn.com/downloads91/ebook/348025/DEV275_05_Interaction.pdf · What Is an Interaction Diagram? An interaction diagram shows

6

Sequence diagramsCollaboration diagramsInteraction diagram comparison

Where Are We?

Page 7: Essentials of Visual Modeling with UML Module 5 ...read.pudn.com/downloads91/ebook/348025/DEV275_05_Interaction.pdf · What Is an Interaction Diagram? An interaction diagram shows

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

Page 8: Essentials of Visual Modeling with UML Module 5 ...read.pudn.com/downloads91/ebook/348025/DEV275_05_Interaction.pdf · What Is an Interaction Diagram? An interaction diagram shows

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( )

Page 9: Essentials of Visual Modeling with UML Module 5 ...read.pudn.com/downloads91/ebook/348025/DEV275_05_Interaction.pdf · What Is an Interaction Diagram? An interaction diagram shows

9

Sequence Diagram Contents: Objects

:RegisterForCoursesForm :RegistrationController SWTSU Catalog : CourseCatalogSystem

Anonymous Objects

Lifelines

Named Object

Page 10: Essentials of Visual Modeling with UML Module 5 ...read.pudn.com/downloads91/ebook/348025/DEV275_05_Interaction.pdf · What Is an Interaction Diagram? An interaction diagram shows

10

:RegisterForCoursesForm :RegistrationController SWTSU Catalog : CourseCatalogSystem

: Student : Course Catalog

Sequence Diagram Contents: Actor

Actor instances

Page 11: Essentials of Visual Modeling with UML Module 5 ...read.pudn.com/downloads91/ebook/348025/DEV275_05_Interaction.pdf · What Is an Interaction Diagram? An interaction diagram shows

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( )

Page 12: Essentials of Visual Modeling with UML Module 5 ...read.pudn.com/downloads91/ebook/348025/DEV275_05_Interaction.pdf · What Is an Interaction Diagram? An interaction diagram shows

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( )

Page 13: Essentials of Visual Modeling with UML Module 5 ...read.pudn.com/downloads91/ebook/348025/DEV275_05_Interaction.pdf · What Is an Interaction Diagram? An interaction diagram shows

13

Sequence diagramsCollaboration diagramsInteraction diagram comparison

Where Are We?

Page 14: Essentials of Visual Modeling with UML Module 5 ...read.pudn.com/downloads91/ebook/348025/DEV275_05_Interaction.pdf · What Is an Interaction Diagram? An interaction diagram shows

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

Page 15: Essentials of Visual Modeling with UML Module 5 ...read.pudn.com/downloads91/ebook/348025/DEV275_05_Interaction.pdf · What Is an Interaction Diagram? An interaction diagram shows

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( )

Page 16: Essentials of Visual Modeling with UML Module 5 ...read.pudn.com/downloads91/ebook/348025/DEV275_05_Interaction.pdf · What Is an Interaction Diagram? An interaction diagram shows

16

Collaboration Diagrams Contents: Objects

Objects

: RegisterForCoursesForm

: RegistrationController SWTSU Catalog : CourseCatalogSystem

Page 17: Essentials of Visual Modeling with UML Module 5 ...read.pudn.com/downloads91/ebook/348025/DEV275_05_Interaction.pdf · What Is an Interaction Diagram? An interaction diagram shows

17

Collaboration Diagram Contents: Actors

: Student : Course Catalog

: RegisterForCoursesForm

: RegistrationController SWTSU Catalog : CourseCatalogSystem

Page 18: Essentials of Visual Modeling with UML Module 5 ...read.pudn.com/downloads91/ebook/348025/DEV275_05_Interaction.pdf · What Is an Interaction Diagram? An interaction diagram shows

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( )

Page 19: Essentials of Visual Modeling with UML Module 5 ...read.pudn.com/downloads91/ebook/348025/DEV275_05_Interaction.pdf · What Is an Interaction Diagram? An interaction diagram shows

19

Sequence diagramsCollaboration diagramsInteraction diagram comparison

Where Are We?

Page 20: Essentials of Visual Modeling with UML Module 5 ...read.pudn.com/downloads91/ebook/348025/DEV275_05_Interaction.pdf · What Is an Interaction Diagram? An interaction diagram shows

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

Page 21: Essentials of Visual Modeling with UML Module 5 ...read.pudn.com/downloads91/ebook/348025/DEV275_05_Interaction.pdf · What Is an Interaction Diagram? An interaction diagram shows

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

Page 22: Essentials of Visual Modeling with UML Module 5 ...read.pudn.com/downloads91/ebook/348025/DEV275_05_Interaction.pdf · What Is an Interaction Diagram? An interaction diagram shows

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

Page 23: Essentials of Visual Modeling with UML Module 5 ...read.pudn.com/downloads91/ebook/348025/DEV275_05_Interaction.pdf · What Is an Interaction Diagram? An interaction diagram shows

23

Exercise

Given:A set of objects and their links and messages

Produce:A sequence diagramA collaboration diagram