160 likes | 316 Views
Sequence and Collaboration Diagrams. University of Sunderland. Purpose. Used to describe how subsystems and objects interact to produce the behavior of the system.
E N D
Sequence and Collaboration Diagrams University of Sunderland
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.
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!
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)
Technique for Construction • Specify behavior • List class roles • Draw lifelines • Identify activations • Identify messages • Iterate
Sample Sequence Diagram Role1 Role2 Role3 Role4 Class Role Activation Message Lifeline Recursive Activation
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.
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.,
Activation • Shown by a box over a lifeline • Represents an active role • May call itself recursively
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
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)
Technique for Construction • Specify behavior. • List class roles. • Identify association roles. • Define message flows • Iterate
Sample Collaboration Diagram A Class Role An Anonymous Role RoleName: ClassName :ClassName A Message An Association Role :ClassName
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
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.