Docsity

Understanding Interaction Diagrams in UML: Communication and Sequence Diagrams, Slides of Java Programming

Partial preview of the text

Download Understanding Interaction Diagrams in UML: Communication and Sequence Diagrams and more Slides Java Programming in PDF only on Docsity!

Interaction Diagram Notation

Objectives

• Read basic UML Interaction (Communication

and Sequence) Diagram notation

Object-Oriented Decomposition

  • The modeling genre of choice for most object-oriented designers is the Unified Modeling Language.
  • The most important activity in object-oriented design is assigning responsibility to objects.
  • The preferred tool to assist object-oriented designers in assigning responsibility to objects are the two UML interaction diagrams.

Introduction

• Why do objects exist?

  • To perform an activity to help fulfill a system’s

purpose

• Interaction Diagrams are used to model

system dynamics

  • How do objects change state?
  • How do objects interact (message passing)?

Communication & Sequence

Diagrams (2)

  • Both diagram types are semantically equivalent, however, they may not show the same information - Communication Diagrams emphasize the structural

organization of objects, while Sequence Diagrams

emphasize the time ordering of messages

  • Communication Diagrams explicitly show object

linkages, while links are implied in Sequence

Diagrams

Interaction Diagrams Are Valuable

  • Interaction Diagrams provide a thoughtful, cohesive, common starting point for inspiration during programming
  • Patterns, principles, and idioms can be applied to improve the quality of the Interaction Diagrams

Communication Diagrams

  • Objects are connected with numbered (sequenced) arrows along links to depict information flow
  • Arrows are drawn from the interaction source
  • The object pointed to by the arrow is referred to as the target
  • Arrows are numbered to depict their usage order within the scenario
  • Arrows are labeled with the passed message

Example Communication

Diagram

:ClassAInstance

:ClassBInstance

2: message2()1: message1()

message1()

Basic Communication Diagram

Notation

• Link - connection path between two objects

(an instance of an association)

• Message - represented with a message

expression on an arrowed line between

objects

• Sequence Number - represents the order in

which the flows are used

Basic Communication Diagram

Notation (2)

• Conditional Message

  • Seq. Number [ variable = value ] : message()
  • Message is sent only if clause evaluates to true

• Iteration (Looping)

  • Seq. Number * [ i := 1..N ] : message()
  • “*” is required; [ ... ] clause is optional

Sequence Diagrams

  • Correspond to one scenario within a Use Case
  • Model a single operation within a System over time
  • Identify the objects involved with each scenario
  • Identify the passed messages and actions that occur during a scenario
  • Identify the required response of each action

Example Sequence Diagram

:ClassAInstance :ClassBInstance

message1()

message2()

message1()

Basic Sequence Diagram

Notation

• Links - Sequence Diagrams do not show links

• Message - represented with a message

expression on an arrowed line between

objects

Basic Sequence Diagram

Notation (2)

• Object Lifeline - the vertical dashed line

underneath an object

  • Objects do not have a lifeline until they are

created

  • The end of an object’s life is marked with an “X” at

the end of the lifeline

  • Passage of time is from top to bottom of diagram