Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 10: Statecharts.

Slides:



Advertisements
Similar presentations
State Diagram 1. State diagram: Shows the behavior of one object. They describe all of the possible states that a particular object can get into and how.
Advertisements

State Charts Mehran Najafi. Reactive Systems A reactive, event-driven, object is one whose behavior is best characterized by its response to events dispatched.
Karolina Muszyńska Based on: S. Wrycza, B. Marcinkowski, K. Wyrzykowski „Język UML 2.0 w modelowaniu SI”
UML State chart/machine diagram State machine diagram is a behavior diagram which shows discrete behavior of a part of designed system through finite state.
ESE Einführung in Software Engineering 7. Modeling Behaviour Prof. O. Nierstrasz.
1 Behavioral Modeling Chapter 8. 2 Key Ideas Behavioral models describe the internal dynamic aspects of an information system that supports business processes.
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.
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.
5/24/2015CPSC , CPSC , Lecture 71 Software Engineering, CPSC , CPSC , Lecture 7.
Systems Analysis and Design in a Changing World, Fourth Edition
Slide 6B.1 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. An Introduction to Object-Oriented Systems Analysis and Design with.
Slide 1 Systems Analysis & Design CS183 Spring Semester Dr. Jonathan Y. Clark Course Website:
Slide 10B.1 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. An Introduction to Object-Oriented Systems Analysis and Design with.
THE OBJECT-ORIENTED DESIGN WORKFLOW Statechart Diagrams.
Advanced Behavioral Modeling
Slide 1 Chapter 8 Behavioral Modeling. Slide 2 Key Ideas Behavioral models describe the internal dynamic aspects of an information system that supports.
TK2023 Object-Oriented Software Engineering CHAPTER 6 SYSTEM SEQUENCE DIAGRAMS.
Chapter 7: The Object-Oriented Approach to Requirements
State and Sequence Diagrams Modelling dynamic information So far we have seen: Use Case Diagrams – requirements capture, interface.
State Machine Diagram Chapter 10. State Machine Diagram Used to describe system behavior.
Lecture 4 Finite State Machine CS6133 Software Specification and Verification.
Chapter 10 State Machine Diagrams
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 8: Modelling Interactions and Behaviour.
מידול התנהגותי 1. Today’s Session Sequence Diagrams State Machines 2.
1 Object-Oriented Modeling Using UML (2) CS 3331 Fall 2009.
Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering.
NJIT Modeling Behavior in State Chart Diagrams Chapter 29 Rafael Mello.
The Object-Oriented Approach to Requirements
4 2009/10 Object Oriented Technology 1 Topic 4: The Object-Oriented Approach to Requirements Adopted from: Ch.7 The Object-Oriented Approach to Requirements.
Systems Analysis and Design in a Changing World, Fifth Edition
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 9: Interaction.
Object-Oriented Modeling Using UML CS 3331 Section 2.3 of Jia 2003.
Sequence & Statechart Diagrams Month Day, Year. Agenda Training Plan Overview Actors and Use Case Diagrams Sequence Diagrams Diagram Elements Evolution.
Behavioral Modeling Chapter 8.
Session 21 Applying the Basic Statechart to the Case Study Written by Thomas A. Pender Published by Wiley Publishing, Inc. October 27, 2011 Presented by.
UML-1 3. Capturing Requirements and Use Case Model.
CSIS3600 System Analysis and Design Statechart Diagrams.
1 A Student Guide to Object- Oriented Development Chapter 7 State Diagrams.
7 Systems Analysis and Design in a Changing World, Fifth Edition.
Discovering object interaction. Use case realisation The USE CASE diagram presents an outside view of the system. The functionality of the use case is.
Information System Design IT60105
Use Case Driven Analysis Requirements Use Case Use Case Description System Sequence Diagram Chapter 5.
Software Engineering Design & Modeling Statechart Diagram.
1 Kyung Hee University Diagram Editor : Design View Spring 2001.
Chapter 5 Implementing UML Specification (Part II) Object-Oriented Technology From Diagram to Code with Visual Paradigm for UML Curtis H.K. Tsang, Clarence.
1 Kyung Hee University Statecharts Spring Kyung Hee University Specifying Objects’ Behaviour  Interaction diagrams show message-passing behaviour.
OMT Modeling 1. Object Model : presented by the object model and the data dictionary. 2. Dynamic Model: presented by the state diagrams and event flow.
Systems Analysis and Design in a Changing World, Fourth Edition
States.
UML: State Chart Diagrams
CS3773 Software Engineering Lecture 06 UML State Machines.
State Chart diagram Week objective Describe State chart Diagrams in Dynamic Modelling 2.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 10: Statecharts.
Modeling Object Lifecycles and State-Dependent Behavior ©SoftMoore ConsultingSlide 1.
2/25/2016COSC , Lecture 191 Real-Time Systems, COSC , Lecture 19 Stefan Andrei.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 6: Restaurant.
7 Systems Analysis – ITEC 3155 The Object Oriented Approach – Use Cases.
1 7 Systems Analysis and Design in a Changing World, 2 nd Edition, Satzinger, Jackson, & Burd Chapter 7 The Object-Oriented Approach to Requirements.
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 Advanced UML State Diagrams.
Systems Analysis and Design in a Changing World, Fourth Edition
State Machine Diagram.
State Machine Diagrams
State Machine Diagrams
UML State Diagrams.
CS251 – Software Engineering Lectures 11 State Diagrams
States.
Object Oriented System Design
States.
Modeling Behavior in Statechart Diagrams
Presentation transcript:

Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 10: Statecharts

Practical Object-Oriented Design with UML 2e Slide 1/2 ©The McGraw-Hill Companies, 2004 Specifying Behaviour ●Interaction diagrams –show how object behave in particular interactions –do not specify all the possible behaviours of objects ●Different notation is needed to summarize the overall behaviour of objects ●UML defines statecharts for this purpose

Practical Object-Oriented Design with UML 2e Slide 1/3 ©The McGraw-Hill Companies, 2004 State-dependent Behaviour ●Objects respond differently to the same stimulus at different times ●This is modelled by defining a set of states –an object can be in one state at any time –the state it is in determines how it responds to events detected or messages received –in particular, an event can cause the object to move from one state to another (a transition)

Practical Object-Oriented Design with UML 2e Slide 1/4 ©The McGraw-Hill Companies, 2004 States, Events and Transitions ●A simple statechart for a CD player:

Practical Object-Oriented Design with UML 2e Slide 1/5 ©The McGraw-Hill Companies, 2004 Statechart Semantics ●A statechart defines the behaviour of instances of a given class ●An object is in one active state at a time ●Events may be received at any time ●An event can trigger a transition –a transition from the active state will fire if it is labelled with the event just received ●The transition leads to the next active state

Practical Object-Oriented Design with UML 2e Slide 1/6 ©The McGraw-Hill Companies, 2004 Initial and Final States ●Model the creation and destruction of objects

Practical Object-Oriented Design with UML 2e Slide 1/7 ©The McGraw-Hill Companies, 2004 Non-determinism ●Sometimes there are two transitions with the same event label leaving a state ●Some systems are non-deterministic –but usually the non-determinism can be removed by adding more information

Practical Object-Oriented Design with UML 2e Slide 1/8 ©The McGraw-Hill Companies, 2004 Guard Conditions ●Conditions added to events indicate when a transition can fire

Practical Object-Oriented Design with UML 2e Slide 1/9 ©The McGraw-Hill Companies, 2004 Actions ●Actions are performed when a transition fires

Practical Object-Oriented Design with UML 2e Slide 1/10 ©The McGraw-Hill Companies, 2004 Entry and exit actions ●Entry and exit actions are properties of states –they are performed whenever an object arrives at or leaves the state, respectively

Practical Object-Oriented Design with UML 2e Slide 1/11 ©The McGraw-Hill Companies, 2004 Activities ●Activities are also properties of states –they are performed while the object is in a state –unlike actions, they can be interrupted by new events

Practical Object-Oriented Design with UML 2e Slide 1/12 ©The McGraw-Hill Companies, 2004 Completion Transitions ●If an activity completes uninterrupted it can trigger a completion transaction –these are transitions without event labels

Practical Object-Oriented Design with UML 2e Slide 1/13 ©The McGraw-Hill Companies, 2004 Internal Transitions ●Internal transitions do not change state –and so do not execute entry and exit actions

Practical Object-Oriented Design with UML 2e Slide 1/14 ©The McGraw-Hill Companies, 2004 Composite States ●Composite states group together states –this can simplify a statechart by grouping together states with similar behaviour ●An object still has one ‘bottom-level’ active state –but may be in a composite state as well

Practical Object-Oriented Design with UML 2e Slide 1/15 ©The McGraw-Hill Companies, 2004 A Composite State

Practical Object-Oriented Design with UML 2e Slide 1/16 ©The McGraw-Hill Companies, 2004 Properties of Composite States ●Transitions –from a composite state apply to all substates –to a composite state go to the state indicated by a nested initial state –can cross composite state boundaries ●Composite states can have activities and entry and exit actions ●A final state in a composite triggers a completion transition from the composite

Practical Object-Oriented Design with UML 2e Slide 1/17 ©The McGraw-Hill Companies, 2004 A Complex Composite State

Practical Object-Oriented Design with UML 2e Slide 1/18 ©The McGraw-Hill Companies, 2004 History States ●Often an object needs to ‘return to the previous state’ ●This can be done by defining conditions –such as ‘[if the last state was Playing]’ ●Composite states can have a history state –this ‘remembers’ the last active substate –a transition to a history state makes that substate active again

Practical Object-Oriented Design with UML 2e Slide 1/19 ©The McGraw-Hill Companies, 2004 Use of a History State

Practical Object-Oriented Design with UML 2e Slide 1/20 ©The McGraw-Hill Companies, 2004 Complete CD Player Statechart

Practical Object-Oriented Design with UML 2e Slide 1/21 ©The McGraw-Hill Companies, 2004 Creating a Statechart ●It can be hard to identify all necessary states ●Statecharts can be developed incrementally –consider individual sequences of events received by an object –these might be specified on interaction diagrams –start with a statechart for one interaction –add states as required by additional interactions

Practical Object-Oriented Design with UML 2e Slide 1/22 ©The McGraw-Hill Companies, 2004 Ticket Machine ●Consider a ticket machine with two events –select a ticket type –enter a coin ●Basic interaction is to select a ticket and then enter coins –model this as a ‘linear’ statechart

Practical Object-Oriented Design with UML 2e Slide 1/23 ©The McGraw-Hill Companies, 2004 Refining the Statechart ●This can be improved by adding ‘loops’ –the number of coins entered will vary: entry will continue until the ticket is paid for –the whole transaction can be repeated

Practical Object-Oriented Design with UML 2e Slide 1/24 ©The McGraw-Hill Companies, 2004 Adding Another Interaction ●The user could enter a coin before selecting a ticket ●A ‘coin’ transition from the ‘Idle’ state is needed to handle this event –this transition can’t go to the ‘Paying for Ticket’ state as the ticket is not yet selected –so a new state ‘Inserting Coins’ is required ●The statechart is thus built up step-by-step

Practical Object-Oriented Design with UML 2e Slide 1/25 ©The McGraw-Hill Companies, 2004 Adding a Second Interaction ●If all coins are entered before ticket selected:

Practical Object-Oriented Design with UML 2e Slide 1/26 ©The McGraw-Hill Companies, 2004 Integrating the Interactions ●In fact, events can occur in any sequence:

Practical Object-Oriented Design with UML 2e Slide 1/27 ©The McGraw-Hill Companies, 2004 Time Events ●Suppose the ticket machine times out after 30 seconds –we need to fire a transition that is not triggered by a user-generated event –UML define time events to handle these cases

Practical Object-Oriented Design with UML 2e Slide 1/28 ©The McGraw-Hill Companies, 2004 Activity States ●Activity states defines periods of time when the object is carrying out internal processing –unlike normal activities, these cannot be interrupted by external events –only completion transitions leading from them –useful for simplifying the structure of complex statecharts

Practical Object-Oriented Design with UML 2e Slide 1/29 ©The McGraw-Hill Companies, 2004 Returning Change ●Use an activity state to calculate change

Practical Object-Oriented Design with UML 2e Slide 1/30 ©The McGraw-Hill Companies, 2004 Ticket Machine Statechart