PB007 Software Engineering I — Interaction Diagrams, Sequence Diagram1 Interaction Diagrams, Sequence Diagram PB007 Software Engineering I Lukáš Daubner daubner@mail.muni.cz PB007 Software Engineering I — Interaction Diagrams, Sequence Diagram2 Interaction Diagrams ̶ Model collaboration between classes/objects/actors ̶ i.e., communication between them ̶ Describes: ̶ Method execution ̶ Scenarios ̶ Collaboration of subsystems ̶ … ̶ In general, they model behavior and communication between two and more objects ̶ In contrast to State Diagram, which focuses only on inner behavior of one object PB007 Software Engineering I — Interaction Diagrams, Sequence Diagram3 Communication Diagram ̶ Captures the communication with focus on relationships between objects ̶ Interaction is considered as their entanglement ̶ From the object point of view, they describes detailed execution of a use case (or its part) ̶ Again, everything must be consistent with Class Diagram ̶ Link can exist only if there is a reference (association or dependency) ̶ Messages are method calls on receiving object ̶ We work with object – instances of classes PB007 Software Engineering I — Interaction Diagrams, Sequence Diagram4 Communication Diagram – Example Link Message Object Object Creation Message Return Message PB007 Software Engineering I — Interaction Diagrams, Sequence Diagram5 Sequence Diagram ̶ Captures the communication with focus on time-based ordering of messages ̶ Interaction is considered as a sequence of messages ̶ From the object point of view, they describes detailed execution of a use case (or its part) ̶ Again, everything must be consistent with Class Diagram ̶ Link can exist only if there is a reference (association or dependency) ̶ Messages are method calls on receiving object ̶ We work with object – instances of classes ̶ Mind the ordering, objects cannot receive message before their creation ̶ Calls in one context must be in the same activation (focus of control) PB007 Software Engineering I — Interaction Diagrams, Sequence Diagram6 Sequence Diagram – Example Return message Message Lifeline Activation Creation message Time PB007 Software Engineering I — Interaction Diagrams, Sequence Diagram7 Sequence Diagram – Example Nested activation Destruction message PB007 Software Engineering I — Interaction Diagrams, Sequence Diagram8 Combined Fragments ̶ Divides the sequence diagram into areas with different behavior ̶ They include operator, at least one operand and zero or more conditions ̶ Examples of major operators: ̶ opt (option) – one operand, which is executed only if the specified condition is satisfied ̶ alt (alternatives) – multiple operands, only the one with the satisfied condition is executed ̶ loop – repeated execution of the operand ̶ break – executed if its condition is satisfied, and it terminates the execution cycle PB007 Software Engineering I — Interaction Diagrams, Sequence Diagram9 Combined Fragments – Example PB007 Software Engineering I — Interaction Diagrams, Sequence Diagram10 Combined Fragments – Example PB007 Software Engineering I — Interaction Diagrams, Sequence Diagram11 You gotta do what you gotta do Task for this week ̶ Process the feedback ̶ Based on the Use Case Diagram and Design Class Diagram, think about the interaction between the objects that are participating in the use case ̶ You can write it down as a pseudocode – it could help you ̶ Choose three cases and model them into three Sequence Diagram ̶ If you need to change something in Design Class Diagram, just do it, no worries. ̶ Do your part in peer review