© M.E. Fayad SJSU -- CmpE Software System Engineering Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering San José State University One Washington Square San José, CA
L3-6a-S2 Interactions © M.E. Fayad SJSU – CmpE M.E. Fayad 2 Lesson 3-6a: Interactions
L3-6a-S3 Interactions © M.E. Fayad SJSU – CmpE M.E. Fayad Lesson Objectives 3 Define Interactions, Messages, Sequencing Understand flow of control: î Flow of control by time î Flow of control by organization Show the correspondence between classes and interaction diagrams
L3-6a-S4 Interactions © M.E. Fayad SJSU – CmpE M.E. Fayad In UML, you can model the dynamic aspects of a system using interactions Use interaction to model the flow of control within an operation, a class, a component, a use case, or the system as a whole 4 Interactions (1)
L3-6a-S5 Interactions © M.E. Fayad SJSU – CmpE M.E. Fayad An interaction is a behavior that comprises a set of messages exchanged among a set of objects within a context to accomplish a purpose 5 Interactions (2)
L3-6a-S6 Interactions © M.E. Fayad SJSU – CmpE M.E. Fayad A message is a specification of a communication between objects that conveys information with the expectation that activity will ensure Messages –Can involve the invocation of an operation or the sending of a signal –May also encompass the creation and destruction of other objects 6 Messages (1)
L3-6a-S7 Interactions © M.E. Fayad SJSU – CmpE M.E. Fayad When you pass a message, the result is an action. An Action may result in a change of state In UML, the following actions are possible: –Call – invokes an operation on an object –Return – returns a value to the caller –Send – Sends a signal to an object –Create – Creates an object –Destroy – Destroys an object 7 Messages (2)
L3-6a-S8 Interactions © M.E. Fayad SJSU – CmpE M.E. Fayad 8 Messages (3)
L3-6a-S9 Interactions © M.E. Fayad SJSU – CmpE M.E. Fayad When an object passes a message to another, the receiving objects might in turn send a message to another object This stream of messages form a sequence Can explicitly model the order of the messages by prefixing each message with a sequence number set apart by a colon separator 9 Sequencing (1)
L3-6a-S10 Interactions © M.E. Fayad SJSU – CmpE M.E. Fayad Distinguish one flow of control from another by prefixing a message’s sequence number with the name of the process or thread –E.g., D5 : ejectHatch (3) The operation ejectHatch is dispatched as the fifth message in the sequence rooted by the process or thread named D 10 Sequencing (2)
L3-6a-S11 Interactions © M.E. Fayad SJSU – CmpE M.E. Fayad Specify a procedural or nested flow of control using a filled solid arrowhead –E.g., Specify a flat flow of control using a stick arrowhead –E.g., 11 Flow of Control
L3-6a-S12 Interactions © M.E. Fayad SJSU – CmpE M.E. Fayad 12 Procedural Sequence
L3-6a-S13 Interactions © M.E. Fayad SJSU – CmpE M.E. Fayad 13 Flat Sequence
L3-6a-S14 Interactions © M.E. Fayad SJSU – CmpE M.E. Fayad Two types of interaction diagrams in UML –Sequence diagram –Collaboration diagram The two diagrams are isomorphic –Can take one and transform it into the other without loss of information 14 Interaction Diagrams
L3-6a-S15 Interactions © M.E. Fayad SJSU – CmpE M.E. Fayad 15 Flow of Control by Time
L3-6a-S16 Interactions © M.E. Fayad SJSU – CmpE M.E. Fayad 16 Flow of Control by Organization
L3-6a-S17 Interactions © M.E. Fayad SJSU – CmpE M.E. Fayad 17 Correspondence between Class & Interaction Diagrams
L3-6a-S18 Interactions © M.E. Fayad SJSU – CmpE M.E. Fayad 1. Define: Interaction, messages, and sequencing. 2. Describe a flow of control by time with an illustrated example. 3. Describe a flow of control by time with an illustrated example. 4. Use stability model to model the following: a. Interactions b. Messages c. Sequencing d. Flow of control 18 Discussion Questions