180 likes | 192 Views
Learn about interactions, messages, and sequencing in object-oriented analysis and design. Understand how to model the flow of control in a system and the correspondence between classes and interaction diagrams.
E N D
Advanced Object-Oriented Analysis & Design Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering San José State University One Washington Square San José, CA 95192-0180 http://www.engr.sjsu.edu/~fayad SJSU -- CmpE
Lesson 26: Interactions 2 SJSU – CmpE --- M.E. Fayad
Lesson Objectives • 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 3 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 Interactions (1) 4 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 Interactions (2) 5 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 Messages (1) 6 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 Messages (2) 7 SJSU – CmpE --- M.E. Fayad
Messages (3) 8 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 Sequencing (1) 9 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 Sequencing (2) 10 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., Flow of Control 11 SJSU – CmpE --- M.E. Fayad
Procedural Sequence 12 SJSU – CmpE --- M.E. Fayad
Flat Sequence 13 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 Interaction Diagrams 14 SJSU – CmpE --- M.E. Fayad
Flow of Control by Time 15 SJSU – CmpE --- M.E. Fayad
Flow of Control by Organization 16 SJSU – CmpE --- M.E. Fayad
Correspondence between Class & Interaction Diagrams 17 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 Discussion Questions 18 SJSU – CmpE --- M.E. Fayad