UML Discussion on State Machines Perfectly static system is intensely uninteresting Because nothing ever happens.

Slides:



Advertisements
Similar presentations
NCKU EE RTES LAB.1 Unified Modeling Language - Events and State Machines.
Advertisements

UML State Machine Diagrams and Modeling
State Charts Mehran Najafi. Reactive Systems A reactive, event-driven, object is one whose behavior is best characterized by its response to events dispatched.
Nested state diagrams:Problems with flat state diagram
Concepts & Notations. Acknowledgements  The material in this tutorial is based in part on: Concurrency: State Models & Java Programming, by Jeff Magee.
Behavioral Modeling: State Diagrams CIS 4800 Kannan Mohan Department of CIS Zicklin School of Business, Baruch College Copyright © 2009 John Wiley & Sons,
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.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
Unified Modeling Language
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.
Unified Modeling Language Unit 4. Dynamic Modeling.
More on Dynamic Models - Page L14-1 Full 2002M.E. Fayad Lesson 14: More about Dynamic Models Object- Oriented Modeling & Applications.
1 CS 691z/791z Topics in Software Engineering Chapter 13: Activity Diagrams & Chapter 19: Basic Statecharts [Arlow and Neustadt, 2002] March 8, 2007.
2007ACS-3913 R. McFadyen1 UML Statechart Diagram A UML Statechart Diagram describes states for an object how/why an objects’ state changes A Statechart.
THE OBJECT-ORIENTED DESIGN WORKFLOW Statechart Diagrams.
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.
Advanced Behavioral Modeling
SE-565 Software System Requirements More UML Diagrams.
University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution.
UML Sequence Diagrams Michael L. Collard, Ph.D. Department of Computer Science Kent State University.
Lecture 4 Finite State Machine CS6133 Software Specification and Verification.
Chapter 10 State Machine Diagrams
1 Object-Oriented Modeling Using UML (2) CS 3331 Fall 2009.
Software Engineering 1 Object-oriented Analysis and Design Chap 29 UML State Machine Diagrams and Modeling.
NJIT Modeling Behavior in State Chart Diagrams Chapter 29 Rafael Mello.
Chapter 5 Implementing UML Specification (Part II) Object-Oriented Technology From Diagram to Code with Visual Paradigm for UML Curtis H.K. Tsang, Clarence.
Guide to State Transition Diagram. 2 Contents  What is state transition diagram?  When is state transition diagram used?  What are state transition.
Behavioral diagrams Lecture p4 T120B pavasario sem.
Object-Oriented Modeling Using UML CS 3331 Section 2.3 of Jia 2003.
Analysis Modeling. Function Modeling & Information Flow  Information is transformed as it flows through a computer-based system. The system accepts input.
OO Methodology Elaboration Iteration 3 – Part 2 Refining Models.
By: David Harel & Eran Grey Presenter: Elizabeth Antony CISC 836.
Software Engineering Design & Modeling Statechart Diagram.
SWT - Diagrammatics Lecture 4/4 - Diagramming in OO Software Development - partB 4-May-2000.
Chapter 5 Implementing UML Specification (Part II) Object-Oriented Technology From Diagram to Code with Visual Paradigm for UML Curtis H.K. Tsang, Clarence.
State Modeling. Introduction A state model describes the sequences of operations that occur in response to external stimuli. As opposed to what the operations.
Object Oriented Analysis & Design & UML (Unified Modeling Language)1 Part VI: Design Continuous Activity Diagams State Diagrams.
12 Chapter 12: Advanced Topics in Object-Oriented Design Systems Analysis and Design in a Changing World, 3 rd Edition.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 UML State Diagrams.
States.
CS3773 Software Engineering Lecture 06 UML State Machines.
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
 Engineering Quality Software.  Today o State Diagrams Jerry Kotuba SYST30009-Engineering Quality Software 2.
Chapter 5 – System Modeling Lecture 9 Section A 27/4/2015 Section B 29/4/2015 1Chapter 5 System modeling.
Modeling Object Lifecycles and State-Dependent Behavior ©SoftMoore ConsultingSlide 1.
Object Oriented Programming and Data Abstraction Earl Huff Rowan University.
State Modeling. Introduction A state model describes the sequences of operations that occur in response to external stimuli. As opposed to what the operations.
UML Review: State Machines. Sept. 17, 2003Lecture 5: CS660 Fall Overview States Transitions Activities Modeling object lifeline Creating well-structured.
From requirements to specification Specification is a refinement of requirements Can be included together as Software Requirements Specifications (SRS)
EKT 421 SOFTWARE ENGINEERING
State transition modeling
Object-oriented and Structured System Models
State Machine Model.
State Machine Diagram.
State Machine Diagrams
Marlon Dumas Institute of Computer Science
Dynamic Modeling of Banking System Case Study - I
Activity and State Transition Diagram
Object Oriented Modeling and Design
State Machine Diagrams
UML Activity Diagrams & State Charts
States.
Object Oriented System Design
Marlon Dumas Institute of Computer Science
States.
UML State Diagrams.
Modeling Behavior in Statechart Diagrams
UML State Diagrams (Ch. 29)
Presentation transcript:

UML Discussion on State Machines

Perfectly static system is intensely uninteresting Because nothing ever happens

Real Systems Dynamic in nature and always something is happening internally or externally. ATM Machine. Robot. Chemical Reaction. Network Router.

Objects Objects work together to realize higher-order behaviors defined by use cases. Object Behavior with respect to time Simple State Continuous

What is State Machine Its abstract It has finite state of conditions of existence called states It has set of actions performed in each state It has set of events which causes state change to well defined rule set.

State Machine Example Possible States RED YELLOW GREEN Flashing Yellow Flashing Red …

What things exhibit state ? Classes Use cases State Machine can be applied to object oriented systems as well as functionally decomposed ones.

Behavioral Elements

State Transition State Machine Guard Event

State Machine Using state machine you can Model behavior of individual object. State Machine illustrates sequential behavior of object.  Statechart Diagrams. ­State to State.  Activity Diagrams. ­Activity to Activity.

Example Payment Authorization Authorizing Authorized Delivered Rejected

Web Application  Not yet logged in. Action: Display the login page  Logged in and viewing the account balance Display the account balance Display logout button, and view transaction button.  Logged in and viewing recent transactions Display recent transactions Display logout button, and view account balance button.  Logged out Display “Goodbye page”

Validate Login/PIN

Word Processing

Brew Controller of coffee machine

Coffee Machine Tank

Sequential Sub states

Concurrent Substates

Food For Thought…. Identify States

Hypothetical State Machine Event Queue  When event is received it is placed in queue of target Event Dispatcher  When delivered to state machine Event Processor  Consumed and event is complete

State Machine Concepts Context  An association to the model element that whose behavior is specified by this state machine States Transitions Event

State Machine Concepts Context States  models a situation during which some (usually implicit) invariant condition holds. Transitions Event

State Simple State  No Substates Initial State  Object comes into being Final State  The entire state machine has completed  A final state cannot have any outgoing transitions

State Machine Concepts Context States Transitions  A transition is a directed relationship between a source state and target state Event

Transition Guard Trigger Source Target Effects

Guard A guard is a Boolean expression that is attached to a transition as a fine-grained control over its firing.  If the guard is true at that time, the transition is enabled, otherwise, it is disabled.

State Machine Concepts Context States Transitions Event  An event is a specification of a type of observable occurrence

Events Call Event  Reception of request to synchronously invoke operation. ­Creation of object ­Deletion of object Time Event  Models expiration of specific deadline.

Events… Signal Event  Reception of asynchronous signal

Events… Change Event  Implicit  Results as a change in some value of object attribute

Practical Implementations Mapping of Statechart to efficient code Common Approaches  Double Nested Switch Statements  Action state tables  Generic state machine interpreters  State Patterns in OO Paradigm

/* States. */ #define IDLE 0 #define DIAL 1 #define ALERTING 2 #define CONNECTED 3 #define BUSY 4 #define RINGING 5 /* Possible inputs */ #define ON_HOOK_IND 0 #define OFF_HOOK_IND 1 #define DIGITS_IND 2 #define CONNECTED_IND 3 #define INCOMING_CALL_IND 4 #define TIMEOUT_IND 5 #define PICKUP_IND 6

int transtab[][] = /* transtab[Input][CurrentState] => NextState */ { /* IDLE DIAL ALERTING CONNECTED BUSY RINGING */ { IDLE, IDLE, BUSY, IDLE, IDLE, IDLE }, /* ON_HOOK_IND */ { DIAL, DIAL, BUSY, IDLE, IDLE, IDLE }, /* OFF_HOOK_IND */ { IDLE, ALERTING, IDLE, IDLE, IDLE, IDLE }, /* DIGITS_IND */ { IDLE, DIAL, ALERTING, IDLE, IDLE, IDLE }, /* CONNECTED_IND */ { RINGING, DIAL, IDLE, CONNECTED, BUSY, RINGING }, /* INCOMING_CALL_IND */ { IDLE, DIAL, BUSY, IDLE, IDLE, IDLE }, /* TIMEOUT_IND */ { IDLE, DIAL, BUSY, IDLE, IDLE, CONNECTED }, /* PICKUP_IND */ }; curstate = transtab[event][curstate]; int curstate = IDLE;

Who defines state transitions ? May Define StateMachine

Who defines statemachine.. Context States Themselves State Tables

Guidelines Create A State Chart When Behavior Differs Based on State Place The Initial State In The Top-Left Corner Place The Final State In The Bottom-Right Corner State Names Should be Simple but Descriptive Question “Black Hole” States Question “Miracle” States Create a Hierarchy of State Charts for Very Complex Entities Name Transition Events in Past Tense

What Next Identify the implementation schemes Use XMI Aim for changes in statemachine which will need no or minimal changes to existing state implementations

Reference