Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 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.

Similar presentations


Presentation on theme: "1 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."— Presentation transcript:

1 1 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

2 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 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 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 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 6 Common UML Interaction Diagram Notation Object Symbol Naming Format Notation An object of an unspecified class. A named object of a specified class. An unnamed object of a specified class.

7 7 Object Stereotype Object Category DescriptionGraphical Notations Actor ObjectAn 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.

8 8 Object Stereotype (cont’d) Object Category DescriptionGraphical 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.

9 9 Messages MessageDescriptionNotation 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.

10 10 Messages (cont’d) MessageDescriptionNotation Return messageMessage 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.)

11 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 12 Sequence Diagrams (cont’d)

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

14 14 Creation & Destruction Object Creation Object Destruction

15 15 Branching Conditional Message Transmission

16 16 Message that Takes Time Message Transmission that Takes Time

17 17 Iteration

18 18 Alternate Message Reception Alternate Message Reception

19 19 Recursion

20 20 Example Life line Creation Deletion

21 21 Example Life line Activation iteration

22 22 Example Life line collective iteration

23 23 Example Concurrent Branch

24 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 25 Collaboration Diagrams (cont’d)

26 26 Example – Telephone System

27 27 Example – Message with Duration

28 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 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 30 Example – An Automatic Teller Machine (cont’d)

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

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

33 33 Example - A Soft Drink Vending Machine

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

35 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 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 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 38 UML Notation

39 39 UML Notation (cont’d) Action or activityDescription entry/ action 1; …; action nUpon entry to the state, the specified actions are performed. exit/ action 1; …; action nUpon exit from the state, the specified actions are performed. do/ activityThe specified activity is performed continuously while in this state. event-name(parameters) [guard-condition] / action 1 ; …; action n An internal transition is fired when the specified event occurs and the specified guard condition is true. The specified actions are performed when the transition is fired.

40 40 UML Notation (cont’d) Initial state Final state State History state Junction state Concurrent composite state Transition

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

42 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 43 Composite State

44 44 Composite State (cont’d)


Download ppt "1 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."

Similar presentations


Ads by Google