sequence and collaboration diagrams

15
Sequence and Collaboration Diagrams University of Sunderland

Upload: niles

Post on 06-Jan-2016

27 views

Category:

Documents


0 download

DESCRIPTION

Sequence and Collaboration Diagrams. University of Sunderland. Purpose. Used to describe how subsystems and objects interact to produce the behavior of the system. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Sequence and Collaboration Diagrams

Sequence and Collaboration Diagrams

University of Sunderland

Page 2: Sequence and Collaboration Diagrams

Purpose

• Used to describe how subsystems and objects interact to produce the behavior of the system.

• Provide complementary representations of the same information. You can convert from sequence diagrams to collaboration diagrams by considering the association roles.

• Collaboration diagrams are the starting point for generating the object and class diagrams.

• Collaboration diagrams are renamed communication diagrams in UML 2.

Page 3: Sequence and Collaboration Diagrams

Recommended Texts• Key text: Stevens and Pooley, 2000, Using UML,

updated edition, Addison-Wesley, ISBN 0-201-64860-1.

• Reference text: Alhir, 1998, UML in a Nutshell, O’Reilly, ISBN: 1-56592-448-7. (The basis for much of these lectures.)

• Advanced text: Graham, 2001, Object-Oriented Methods, 3rd edition, Addison-Wesley, ISBN 0-201-61913-X.

• Several articles are provided—explore them thoroughly in tutorial and at home!

Page 4: Sequence and Collaboration Diagrams

Sequence Diagram Notation

• Sequence diagrams contain the following:– Class roles (subsystem/object/class, actor, and external

system roles in the interaction). These are (usually) drawn across the top of the diagram.

– Lifelines (subsystem/object/class existence). These (usually) extend down the diagram.

– Activations (show when the subsystem/object/class is doing something)

– Messages (communication between roles)

Page 5: Sequence and Collaboration Diagrams

Technique for Construction

• Specify behavior

• List class roles

• Draw lifelines

• Identify activations

• Identify messages

• Iterate

Page 6: Sequence and Collaboration Diagrams

Sample Sequence Diagram

Role1 Role4Role3Role2

Class Role

Lifeline

Activation

Message

Recursive Activation

Page 7: Sequence and Collaboration Diagrams

Class Roles

• Notation is a rectangle containing RoleName:ClassName (both underlined)

• Can be an interface instead of class. • May have a number in the upper right hand

corner giving the number of instances involved.

• Represents an object, class, actor (person), subsystem or external system.

Page 8: Sequence and Collaboration Diagrams

Lifelines

• Dashed or dotted line from past to future or from birth to death if a role with a limited lifespan.

• Death is marked with a large

• May split and merge to represent alternative paths. E.g.,

Page 9: Sequence and Collaboration Diagrams

Activation

• Shown by a box over a lifeline

• Represents an active role

• May call itself recursively

Page 10: Sequence and Collaboration Diagrams

Messages

• Denoted by labeled horizontal arrows• If simply an arrow, represents flow of control.• If shown as:

represents a handshake (e.g., TCP).• If with a half-arrowhead, asynchronous (e.g.,

UDP):• If at an angle rather than horizontal, represents a

time delay:

} paired

Page 11: Sequence and Collaboration Diagrams

Collaboration Diagram Notation

• Forms a context for interactions– May realize use cases– May be associated with operations– May describe the static structure of classes

• Collaboration diagrams contain the following:– Class roles (subsystems/objects/classes/actors/ external

systems) as before.– Association roles (pathways or links over which

messages flow)– Message flows (messages sent between class roles)

Page 12: Sequence and Collaboration Diagrams

Technique for Construction

• Specify behavior.

• List class roles.

• Identify association roles.

• Define message flows

• Iterate

Page 13: Sequence and Collaboration Diagrams

Sample Collaboration Diagram

RoleName: ClassName :ClassName

:ClassName

A Class Role

An Association Role

A Message

An Anonymous Role

Page 14: Sequence and Collaboration Diagrams

Association Roles

• Often classes

• Define the interaction between class roles.

• Multiplicities defined if the Class Roles represent sets of objects

Role-Name:Association-Name

Multiplicity Multiplicity

Page 15: Sequence and Collaboration Diagrams

Message Flows

• Sequence numbers on every message. These can be nested to associate related messages.

• Arrows are the same as those used in sequence diagrams.