© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 UML State Diagrams.

Slides:



Advertisements
Similar presentations
State Charts Mehran Najafi. Reactive Systems A reactive, event-driven, object is one whose behavior is best characterized by its response to events dispatched.
Advertisements

Nested state diagrams:Problems with flat state diagram
UML Statechart semantics Speaker: Fei Mo Tutor: Priv.-Doz. Dr. Thomas Noll Lehrstuhl für Informatik 2 RWTH Aachen SS 07.
State Transition Diagrams Chapter 13
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.
Systems Analysis Requirements structuring Process Modeling
Using Data Flow Diagrams
Using Dataflow Diagrams
State Diagrams A state diagram is a graph whose nodes are states and whose directed arcs are transitions between states. A state diagram specifies the.
1 Introduction to Computability Theory Lecture4: Regular Expressions Prof. Amos Israeli.
Using Dataflow Diagrams
State Diagram. What is State Diagram?  State diagram is used to show the state space of a given class, the events that cause a transition from one state.
State Change Modelling. Aim: To introduce the concept and techniques for describing the changes in state that may occur to an object in its lifetime.
1 Turing Machines. 2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
Advanced Behavioral Modeling
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.
Activity Diagram. C-S 5462 Activity diagram a diagram that represents a sequence of activities similar to flow chart, used in 1960’s and 1970’s an activity.
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 6.1.
Lecture 4 Finite State Machine CS6133 Software Specification and Verification.
Chapter 10 State Machine Diagrams
UML A CTIVITY D IAGRAMS 1 Dr. Hoang Huu Hanh, OST – Hue University hanh-at-hueuni.edu.vn.
Business Informatics Group Institute of Software Technology and Interactive Systems Vienna University of Technology Favoritenstraße 9-11/188-3, 1040 Vienna,
1 Software Engineering Dr. K. T. Tsang Lecture 8 State modeling
The Object-Oriented Approach to Requirements
Guide to State Transition Diagram. 2 Contents  What is state transition diagram?  When is state transition diagram used?  What are state transition.
 2000 Deitel & Associates, Inc. All rights reserved. Optional Case Study - Chapter 3 Outline 3.1 Introduction 3.2 Class Attributes 3.3 Statechart Diagrams.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 UML Sequence Diagrams.
1 Modeling interactions and behavior Lecturer Dr. Mai Fadel.
CSIS3600 System Analysis and Design Statechart Diagrams.
7 Systems Analysis and Design in a Changing World, Fifth Edition.
Information System Design IT60105
State Transition Diagram & UML’s enhancements
1 Kyung Hee University Statecharts Spring Kyung Hee University Specifying Objects’ Behaviour  Interaction diagrams show message-passing behaviour.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 UML Activity Diagrams.
UML Discussion on State Machines Perfectly static system is intensely uninteresting Because nothing ever happens.
Chapter 11 Activity Diagrams. 2 “Activity diagrams are a technique to describe procedural logic, business processes, and work flows” - M. Fowler An activity.
Object Oriented Analysis & Design & UML (Unified Modeling Language)1 Part VI: Design Continuous Activity Diagams State Diagrams.
Sections © Copyright by Pearson Education, Inc. All Rights Reserved.
Systems Analysis and Design in a Changing World, Fourth Edition
States.
CS3773 Software Engineering Lecture 06 UML State Machines.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 26. Review UML behavioral Diagrams – Sequence diagram.
Essentials of Counter-Controlled Repetition Counter-controlled repetition requires: Control variable (loop counter) Initial value of the control variable.
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.
MCS 270 Spring 2014 Object-Oriented Software Development.
Modeling Object Lifecycles and State-Dependent Behavior ©SoftMoore ConsultingSlide 1.
State Machine Diagram Chapter 5 Introduction Pages
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.
1 7 Systems Analysis and Design in a Changing World, 2 nd Edition, Satzinger, Jackson, & Burd Chapter 7 The Object-Oriented Approach to Requirements.
State Modeling. Introduction A state model describes the sequences of operations that occur in response to external stimuli. As opposed to what the operations.
1 Object Oriented Analysis System modeling = Functional modeling + Object modeling + Dynamic modeling Functional modeling = Use cases Object modeling =class.
UML Review: State Machines. Sept. 17, 2003Lecture 5: CS660 Fall Overview States Transitions Activities Modeling object lifeline Creating well-structured.
Formal Languages and Automata FORMAL LANGUAGES FINITE STATE AUTOMATA.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 UML Activity Diagrams.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 Advanced UML State Diagrams.
Activity Diagram.
Chapter 6 Structuring System Requirements: Process Modeling
State Machine Model.
Finite State Machines Dr K R Bond 2009
State Machine Diagrams
Turing Machines 2nd 2017 Lecture 9.
Chapter 6 Structuring System Requirements: Process Modeling
CSC 422 Kutztown University Dr. Spiegel
UML Sequence Diagrams.
States.
Object Oriented System Design
Chapter 5 state Modeling
Chapter 6 Control Statements: Part 2
States.
Copyright © 2015, 2012, 2009 Elsevier Inc. All rights reserved.
Presentation transcript:

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 UML State Diagrams

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2 Objectives  To present the UML state diagram notation  To illustrate uses of state diagrams  To present heuristics for making good state diagrams

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 3 Topics  States, transitions, and events  Deterministic and non-deterministic finite automata  UML state diagrams  State symbol compartments  External and internal transitions  Sequential composite states  State diagram heuristics

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 4 States, Transitions, Events A state is a mode or condition of being. A transition is a change from one state to another. An event is a noteworthy occurrence at a particular time. A state is a mode or condition of being. A transition is a change from one state to another. An event is a noteworthy occurrence at a particular time.

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5 Finite Automata  A formal model that abstracts everything about an entity except its states and state transitions  A finite state machine or finite automaton specification must Describe all states unambiguously (names) Describe all transitions by stating the source and destination states and the triggering event Designate an initial state

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 6 Determinism  Finite automata may be deterministic No spontaneous transitions Any event in any state triggers a transition to exactly one state  Non-deterministic finite automata—any machine that is not deterministic  Every non-deterministic finite automaton is equivalent to a deterministic automaton, so we consider only deterministic machines

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7 UML State Diagrams  Represent states by rounded rectangles containing the state name  Represent transitions by solid arrows labeled with one or more transition strings  Transition strings Describe triggering circumstances Actions that result  Initial pseudo-state designates the initial state  Optional final state represents halting

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 8 State Diagram Example

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9 State Transition String Format  event-signature—The empty string or an event name followed by a list of event-parameters enclosed in parentheses parentheses may be omitted if there are no parameters parameter-name : type  parameter-name is a simple name  type is a type description in an arbitrary format  type may be omitted along with the colon  guard —a Boolean expression in square brackets Format not specified in UML  action-expression—description of a computation done when the transition occurs Format not specified in UML Optional; if omitted, so is the slash event-signature guard / action-expression

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 10 Transition String Examples  buttonPress  buttonPress( modifiers : Modifer[*] )  buttonPress / closeWindow  buttonPress [enabled]  buttonPress [enabled] / closeWindow  [mode = active]  / closeWindow  buttonPress[enabled], mouseClick

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 11 State Diagram Execution Model 1  The machine always has a current state.  The machine begins execution in its unique initial state.  When an event occurs: If it matches an event-signature on a transition from the current state and the guard is absent or true, the transition occurs and the current state becomes the target state. If it does not match an event-signature or the guard is false, no change of state occurs.

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 12 State Diagram Execution Model 2  If the computation occurring in the current state completes, and there is a transition from the current state with no event- signature: If the guard is absent or true then the target state becomes the current state. If the guard is false, no change of state occurs.  If a transition has an action-expression, the action occurs when the transition takes place.  If a final state becomes the current state, the machine halts.

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 13 State Symbol Compartments As many as three compartments Name compartment  Optional; may be attached to a tab  Pathname Internal transitions  Internal transition specifications, one per line  Transition processed without causing a state change  Optional Nested diagram  Optional

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 14 Internal Transition Specifications  May be a transition string or a string of the following form: action-label / action-expression  action-label—one of the items from the table on the next slide  action-expression—description of a computation in a format not specified by UML

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 15 Internal Transition Action Labels Action LabelMeaning entry Execute the associated action-expression (an entry action) upon state entry. exit Execute the associated action-expression (an exit action) upon state exit. do Execute the associated action-expression (a do activity) upon state entry and continue until state exit or action completion. include The action-expression must name a finite automaton. The named automaton is a placeholder for a nested state diagram (discussed below).

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 16 Internal Transition Examples  buttonPress / beep  keyPress( SPACE ) / count++  timeout [mode = alert] / displayAlertMsg  entry / count := 0; sum := 0  exit / ring bell  do / display flashing light  include / OrderProcessing

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 17 State Diagram with Internal Transitions Example

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 18 Nested State Diagrams  A state without a nested state compartment is a simple state; one with a nested state compartment is a composite state

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 19 Types of Composite States  Sequential composite state—The nested state compartment is a single region with sub-states or inner states and transitions.  Concurrent composite state—The nested state compartment is comprised of two or more regions separated by concurrent region boundary lines (dashed lines) containing inner states and transitions.

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 20 Sequential Composite States  When a sequential composite state is entered, so is one of its inner states (and likewise for further nested states), and they jointly become the current state. Nested diagrams must have initial states or transitions must go directly to inner states  When a sequential composite state is exited, so is the current inner state (and likewise for further nested states).

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 21 Sequential Composite States Example

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 22 Action Execution Order When an initial state is entered, the state’s entry actions are executed, followed by the entry actions of any initial sub-states. When a transition causes exit from simple state A and entry to simple state B 1.Simple state A’s exit actions are executed; 2.The exit actions of any exited composite states enclosing A are executed, in order from innermost to outermost exited states; 3.The transition action is executed; 4.The entry actions of any entered composite states enclosing B are executed, in order from outermost to innermost entered states; and 5.Simple state B’s entry actions are executed.

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 23 Action Execution Order Exercise

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 24 Stubbed States  Stub symbol used as a termination and origin point for transitions to and from states in a suppressed nested state diagram  A stub or stub symbol is a short line labeled with the suppressed state name

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 25 Stubbed State Example

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 26 Using Sequential Composite State  Any finite automaton can be described by a state diagram with only simple states.  Sequential composite states simplify state models in two ways: Organize states into hierarchies Consolidate many transitions

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 27 State Diagram Heuristics 1  Check that every non-completion transition arrow is labeled.  Check that no arrow leaves a final state.  Check for black holes (dead states) and white holes (unreachable states).  Label states with adjectives, gerund phrases, or verb phrases.

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 28 State Diagram Heuristics 2  Name events with verb phrases or with noun phrases describing actions.  Name actions with verb phrases.  Combine arrows with the same source and target states.  Use stubs and the include internal transition to decompose large and complicated state diagrams.

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 29 State Diagram Heuristics 3  Make one initial state in every state diagram (including nested state diagrams).  Check that no event labels two or more transitions from a state.  Check that all guards on the same event are exclusive.  Use [else] guards to help ensure that guards are exclusive and exhaustive.

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 30 Summary 1  State diagrams are a powerful UML notation for showing how entities change over time.  Entity states are represented by rounded rectangles, and state changes by labeled transition arrows.  Transition strings allow specification of transition in terms of events and environmental conditions, and allow specification of transition actions

© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 31 Summary 2  Sequential composite states provide a means to show state hierarchies.  They also allow (sometimes radical) reductions in the number of transitions, simplifying models.