1 / 44

Chapter 4 Dynamic Modeling and Analysis (Part I)

Chapter 4 Dynamic Modeling and Analysis (Part I). Object-Oriented Technology From Diagram to Code with Visual Paradigm for UML Curtis H.K. Tsang, Clarence S.W. Lau and Y.K. Leung McGraw-Hill Education (Asia), 2005. References.

talex
Download Presentation

Chapter 4 Dynamic Modeling and Analysis (Part I)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 4Dynamic Modeling and Analysis (Part I) Object-Oriented Technology From Diagram to Code with Visual Paradigm for UML Curtis H.K. Tsang, Clarence S.W. Lau and Y.K. Leung McGraw-Hill Education (Asia), 2005

  2. References • Chapter 4, Object-Oriented Technology: From diagram to code with Visual Paradigm for UML • Chapters 15, 18, 21, The UML User Guide

  3. What You Will Learn • Model message flows using sequence diagrams. • Model message flows using the collaboration diagrams. • Model lifetime behaviors of an object using statechart diagrams. • Model performance of actions of a procedure or an activity using activity diagrams.

  4. Scenario Modeling Techniques – Interaction Diagram • Scenario modeling describes how the objects in a system interact with each other in a scenario. • A scenario is a sequence of events that occurs during one particular execution path within a use case of a system. • Each event involves the interaction of objects passing messages between them.

  5. Scenario Modeling Techniques – Interaction Diagram (cont’d) • An interaction diagram can be used to model the collaborating objects in scenarios, showing the objects involved in the scenario and the messages sent and received by them. • These objects may be external or internal to the system. • The messages represent the invocation of operations of the receiving objects. • Two kinds of interaction diagrams: sequence diagrams and collaboration diagrams. • Sequence diagrams focus on the time sequencing of messages. • Collaboration diagrams focus on the structural organization of the links between collaborating objects.

  6. Common UML Interaction Diagram Notation • Object Symbol

  7. Object Category Description Graphical Notations Actor Object An external entity that interacts with the system. Entity Object An object that models the data in the system. It often represents an object in the problem domain. Object Stereotype

  8. Object Category Description Graphical Notations Boundary Object An object that handles the communication between actor objects and the system. Control Object An object that models the flow of control and functionality that do not naturally belong to entity objects or boundary objects. Object Stereotype (cont’d)

  9. Message Description Notation Procedure call or other nested flow of control The message sender waits for the completion of the procedure call of the message receiver. Asynchronous communication The sender dispatches a message and immediately continues with the next step of execution. Messages

  10. Message Description Notation Return message Message returned from the procedure call. Message with travel delay The message will take a significant amount of time to arrive at the receiving object. (This is only used in sequence diagrams.) Messages (cont’d)

  11. Sequence Diagrams • An interaction diagram models the behavior of a group of objects that work together to achieve a user goal. • A sequence diagram helps us identify a set of collaborating objects involved in a scenario of a use case. • A sequence diagram has two dimensions: the vertical dimension and the horizontal dimension, respectively representing the passage of time and the objects involved in the interaction. • Object icons are placed horizontally at the top of the sequence diagram, and messages are passed between them.

  12. Sequence Diagrams (cont’d)

  13. Life Line & Activation Object with Lifeline Object with Activation

  14. Creation & Destruction Object Creation Object Destruction

  15. Branching Conditional Message Transmission

  16. Message that Takes Time Message Transmission that Takes Time

  17. Iteration Iteration

  18. Alternate Message Reception Alternate Message Reception

  19. Recursion Recursion

  20. Example Creation Life line Deletion

  21. Example Life line iteration Activation

  22. Example Life line collective iteration

  23. Example Concurrent Branch

  24. Collaboration Diagrams • Collaboration diagrams provide another way to model a scenario. • Shows the roles of objects and associations of objects in an instance of collaboration. • Focus on structures of the objects rather than temporal sequence of operations. • In a collaboration diagram, each object is represented by an object icon, and links are used to indicate communication paths on which messages are transmitted. • Collaboration diagram = object diagram + messages between objects. • Messages are presented in the same way as those in a sequence diagram; in fact, sequence diagrams and collaboration diagrams are semantically equivalent.

  25. Collaboration Diagrams (cont’d)

  26. Example – Telephone System

  27. Example – Message with Duration

  28. Example – An Automatic Teller Machine (ATM) • The ATM prompts the user to insert a card. • The user inserts an ATM card. • The ATM prompts the user to input the PIN. • The user enters the PIN. • The ATM asks the bank consortium to verify the ATM card number and PIN. • The bank consortium verifies the ATM card number and PIN with bank. • The bank notifies the bank consortium that the PIN is correct. • The bank consortium notifies the ATM the PIN is correct. • The ATM prompts the user to select a service. • The user selects the withdraw cash service. • The ATM prompts the user to enter the amount to withdraw.

  29. Example 1 – An Automatic Teller Machine (cont’d) • The user enters the amount to withdraw. • The ATM asks the bank consortium to process the request. The bank consortium forwards the request to bank. • The bank confirms the successful execution of the request to the bank consortium which in turn notifies the ATM that the request has been approved. • The ATM displays the successful transaction screen, ejects card and then dispenses cash requested. • The ATM shows the main menu to the user for selecting the next service.

  30. Example – An Automatic Teller Machine (cont’d)

  31. Example – An Automatic Teller Machine (cont’d)

  32. Example – An Automatic Teller Machine (cont’d)

  33. Example - A Soft Drink Vending Machine

  34. Example - A Soft Drink Vending Machine (cont’d)

  35. Dynamic Modeling Techniques Using Statechart Diagrams • The behavior of an entity is not only a direct consequence of its inputs, but it also depends on its preceding state. • The past history of an entity can best be modeled by a finite statechart diagram traditionally named “automata”. • Statechart diagrams (or sometimes referred to as state diagrams) show the different states of an entity. • Statechart diagrams can also show how an entity responds to various events by changing from one state to another. 

  36. What Is a State? • According to Rumbaugh et al. “A state is an abstraction of the attribute values and links of an object. Sets of values are grouped together into a state according to properties that affect the gross behavior of the object.” • For example, consider you have $100,000 in a bank account. The behavior of the withdraw function would be: • balance := balance – withdrawAmount; provided that the balance after the withdrawal is not less than $0; • However, if the account balance becomes negative after a withdrawal, the behavior of the withdraw function would be quite different.

  37. What Is a State?(cont’d) • There are several characteristics of states: • A state occupies an interval of time. • A state is often associated with an abstraction of attribute values of an entity satisfying some condition(s). • An entity changes its state not only as a direct consequence of the current input, but it is also dependent on some past history of its inputs.

  38. UML Notation

  39. UML Notation (cont’d)

  40. UML Notation (cont’d)

  41. Transition • A transition from one state to another takes place instantaneously in response to some external events or internal stimuli.

  42. Transition (cont’d) • A transition is fired when the following conditions are satisfied: • The entity is in the state of the source state. • An event specified in the label occurs. • The guard condition specified in the label is evaluated to be true. • When a transition is fired, the actions associated with it are executed.

  43. Composite State

  44. Composite State (cont’d)

More Related