1Spring 2005 Specification and Analysis of Information Systems Specifying State-based Behavior With UML Statechart Diagrams Eran Toch

Slides:



Advertisements
Similar presentations
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.
Advertisements

Introducing Formal Methods, Module 1, Version 1.1, Oct., Formal Specification and Analytical Verification L 5.
Vered Gafni – Formal Development of Real Time Systems 1 Statecharts Semantics.
1 Statecharts for the many: Algebraic State Transition Diagrams Marc Frappier GRIL – Groupe de recherche en ingénierie du logiciel.
® IBM Software Group © 2006 IBM Corporation Rational Software France Object-Oriented Analysis and Design with UML2 and Rational Software Modeler 04. Other.
Introduction To System Analysis and Design
The Control Unit: Sequencing the Processor Control Unit: –provides control signals that activate the various microoperations in the datapath the select.
Software modeling for embedded systems: static and dynamic behavior.
1 CS 691z/791z Topics in Software Engineering Chapter 13: Activity Diagrams & Chapter 19: Basic Statecharts [Arlow and Neustadt, 2002] March 8, 2007.
1Spring 2005 Specification and Analysis of Information Systems Modeling Behavior with UML Sequence Diagrams Eran Toch
1 CS/CPE 426 Senior Projects Chapter 21: State Machines Chapter 22:Advanced State Machines [Arlow and Neustadt 2005] March 24, 2009.
© Copyright Eliyahu Brutman Programming Techniques Course.
THE OBJECT-ORIENTED DESIGN WORKFLOW Statechart Diagrams.
CS 290C: Formal Models for Web Software Lecture 2: Modeling States with Statecharts Instructor: Tevfik Bultan.
UML Sequence Diagrams Eileen Kraemer CSE 335 Michigan State University.
Advanced Behavioral Modeling
Principle of Functional Verification Chapter 1~3 Presenter : Fu-Ching Yang.
SE-565 Software System Requirements More UML Diagrams.
Department of Computer Science 1 CSS 496 Business Process Re-engineering for BS(CS)
Department of Computer Science 1 CSS 496 Business Process Re-engineering for BS(CS)
UML Sequence Diagrams Michael L. Collard, Ph.D. Department of Computer Science Kent State University.
Lecture 6 Template Semantics CS6133 Fall 2011 Software Specification and Verification.
System Analysis Overview Document functional requirements by creating models Two concepts help identify functional requirements in the traditional approach.
Introduction To System Analysis and design
Lecture 4 Finite State Machine CS6133 Software Specification and Verification.
Chapter 10 State Machine Diagrams
מידול התנהגותי 1. Today’s Session Sequence Diagrams State Machines 2.
1 Object-Oriented Modeling Using UML (2) CS 3331 Fall 2009.
Business Informatics Group Institute of Software Technology and Interactive Systems Vienna University of Technology Favoritenstraße 9-11/188-3, 1040 Vienna,
Benjamin Gamble. What is Time?  Can mean many different things to a computer Dynamic Equation Variable System State 2.
Introduction To System Analysis and Design
Behavioral diagrams Lecture p4 T120B pavasario sem.
Copyright 2002 Prentice-Hall, Inc. Chapter 2 Object-Oriented Analysis and Design Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey.
Object-Oriented Modeling Using UML CS 3331 Section 2.3 of Jia 2003.
1 Interaction diagrams and activity diagrams Speaker: 陳 奕 全 Real-time and Embedded System Lab 15 August 2002.
CS6133 Software Specification and Verification
Lecture 3 Uses Cases Topics UML Use Cases pop quiz Readings: Chapter 3 January 24, 2008 CSCE 492 Software Engineering.
1 Devon M. Simmonds University of North Carolina, Wilmington CSC450 Software Engineering WorkFlow Modeling with Activity Diagrams.
The Unified Modeling Language Part II Omar Meqdadi SE 2730 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Information System Design IT60105
1 Kyung Hee University Statecharts Spring Kyung Hee University Specifying Objects’ Behaviour  Interaction diagrams show message-passing behaviour.
Unified Modeling Language User Guide Section 4 - Basic Behavioral Modeling Chapter 19 – Activity Diagrams.
UML’s StateChart FSM, EFSM in UML Concurrent states Tool support.
Object Oriented Analysis & Design & UML (Unified Modeling Language)1 Part VI: Design Continuous Activity Diagams State Diagrams.
Lecture 9-1 : Intro. to UML (Unified Modeling Language)
States.
CS3773 Software Engineering Lecture 06 UML State Machines.
1 Technical & Business Writing (ENG-715) Muhammad Bilal Bashir UIIT, Rawalpindi.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 26. Review UML behavioral Diagrams – Sequence diagram.
UML (Unified Modeling Language)
® IBM Software Group © 2009 IBM Corporation Module 11: Creating State Machine Diagrams Essentials of Modeling with IBM Rational Software Architect V7.5.
Identifying & Creating Use Cases – Part 2
Object-Oriented Analysis and Design
Marlon Dumas Institute of Computer Science
Unified Modeling Language
Graph Coverage for Specifications CS 4501 / 6501 Software Testing
Advanced state modeling
Software Engineering Chapter 5 (Part 3) System Modeling Dr.Doaa Sami.
UML Activity Diagrams & State Charts
States.
CS/CPE 426 Senior Projects
Systems Analysis and Design in a Changing World, 6th Edition
CS/CPE 426 Senior Projects
Graph Coverage for Specifications CS 4501 / 6501 Software Testing
Marlon Dumas Institute of Computer Science
States.
CSCI1600: Embedded and Real Time Software
Advanced state modeling
CS 791Z State Machines & Advanced State Machines
Presentation transcript:

1Spring 2005 Specification and Analysis of Information Systems Specifying State-based Behavior With UML Statechart Diagrams Eran Toch Spring 2007

2 Outline Introduction to Statecharts Statechart building blocks –States –Transitions Advanced Characteristics –Composite States –Parallel States

3 Modeling Process in UML Intro | Building Blocks | Advanced PhaseActionsOutcome Initiation Raising a business need Business documents Requirements Interviewing stakeholders, exploring the system environment Organized documentation Specification Analyze the engineering aspect of the system, building system concepts Formal specification Design Define architecture, components, data types, algorithms Formal Specification Implementation Program, build, unit-testing, integrate, documentation Testable system Testing & Integration Integrate all components, verification, validation, installation, guidance Testing results, Working sys Maintenance Bug fixes, modifications, adaptation System versions

4 What’s Missing in Behavior Modeling? Intro | Building Blocks | Advanced p : Product : ShooppingCart addProduct (p) customer display() getPrice() checkout () In Sequence diagram, we do not really know how the state of the shopping cart changes.

5 Modeling States How can we model the state of the shopping cart? Depends on: –Object state (e.g. created, destroyed) –Variable assignment –Relation status (i.e. number of items) –Operating methods & processes –History Intro | Building Blocks | Advanced

6 The Automata A machine whose output behavior is not only a direct consequence of the current input, but of some past history of its inputs. Characterized by an internal state which represents this past experience. If the phone is ON, then clicking will turn it off If the phone is OFF, then clicking will turn it on Intro | Building Blocks | Advanced

7 Automata – Mathematical Foundations An Automata is a 5-tuple:  S, , ,S 0  –S is a set of states –  is an alphabet - finite set of symbols –  is the transition function:  : S    S –S 0 is an initial state Many uses: –Stochastic processes (x, y & z are probabilities) –Formal and natural languages (x, y & z are characters) –Complex systems (x, y & z are…) Intro | Building Blocks | Advanced off on click Given a state and an input, the automata jumps to a new state S0S0

8 Automata Modeling with Statecharts A Statechart augments deterministic automata, making them suitable for specifying behavior of complex systems, using: –Visual formalism –Rich alphabet model –State Modularity –Parallel behavior Developed by David Harel (Weizman Inst.) Intro | Building Blocks | Advanced

9 Outline Introduction to Statecharts Statechart building blocks –States –Transitions Advanced Characteristics –Composite States –Parallel States

10 States & Classes Order status: {created, sent, received} hasProblems : boolean gatherItems() updateInventory() sendOrder() received(customer) sendReciept() created sent State view Intro | Building Blocks | Advanced Class view in gathering is received State Transition in problem

11 Activities When holding the state, the component can perform activities. –Can be continuous, taking a specific, or unbounded, time –Activities within a state are sequential –Activities can be interrupted There are special types of activities: enter, exit and event classified activities in gathering do: gatherItems() do: updateInventory() in gathering do: gatherItems() do: updateInventory() Intro | Building Blocks | Advanced created enter: set hasProblems to false do: init gathering list exit: clean log file created enter: set hasProblems to false do: init gathering list exit: clean log file

12 Transitions x x y y event [guard] | action The event that triggers the transition Conditions that must be met for the transition to take place The action that takes place when the transition is taken Intro | Building Blocks | Advanced

13 Events General Events –Method calls : received(customer) –Event signals: inventoryReady Time event –interval expiry; tm(3 days), tm(1000 ms) –calendar/clock time; when(11:50) Change Event: –Change in value of some entity; false(hasProblems) true(hasProblems) Intro | Building Blocks | Advanced created sent in gathering is received inventoryReady tm(3 days) false(hasProblems) received() in problem

14 Guards (Conditions) Boolean expressions. Evaluated when the transition is triggered Types of guards: –Simple predicate: [hasProblems], [x > 0] –Combined predicates: [  hasProblems  (hasProblems  order.sum < 100] –Guards on activities: [active(gatherItems)] –State related (we’ll get back to it later) Intro | Building Blocks | Advanced sent in gathering gatheringFinished [all items were gathered] in problem gatheringFinished [items are not found]

15 Guards - Example Selling Unhappy bid [(value >= 100) AND (value < 200)] Happy bid [value >= 200] bid bid [value < 100] Intro | Building Blocks | Advanced

16 Static Conditional Branching A graphical shortcut for convenient rendering of decision trees [(value >= 100) & (value < 200)] [value >= 200] [value < 100] SellingSelling UnhappyUnhappy HappyHappy bid Intro | Building Blocks | Advanced

17 Empty Transitions A transition can have any combination (including none) of the events, guards and actions When a transition does not have an event, it is taken after all the activities were ended Cleaning do: put water do: put soap do: wash soap do: drain doing nothing Employee rest[break] work Working do: shovel Empty Transition work Intro | Building Blocks | Advanced

18 Guards and Events What’s the difference between the two machines? S1S2 E1 S3 true(C) S1S2 E1 S3 [C] What happens if C changes to True before E1? Intro | Building Blocks | Advanced

19 Actions An executable atomic computation Types of actions –Variable assignment: –Throwing a signal: –Start, or stop activities (and concatenation of actions): sentsent is received received() | status := received sentsent is received received() | throw(InventoryUpdate) sentsent is received | start(sendBill); stop(delivery); x := x+1 Intro | Building Blocks | Advanced

20 Transitions - advanced Self-transitions: Transitions can be directed to the same state: Un-deterministic states – when two transitions are taken in the same time, one of will be taken in an un-deterministic fashion: S2 E1 / c:=c+1 / c=0 S1S2 E1 S3 [C1] Intro | Building Blocks | Advanced

21 How does a Washing Machine Works? On / Off button. Start button (No stop button.) Feedback is given on the current stage (soaking, rinsing, draining, drying) Three plans: –Regular –Delicate (no soaking) –Super delicate (no soaking, no drying) Off can be clicked only before starting, or after finishing Intro | Building Blocks | Advanced

22 Washing Machine Intro | Building Blocks | Advanced

23 Outline Introduction to Statecharts Statechart building blocks –States –Transitions Advanced Characteristics –Composite States –Parallel States

24 State Explosion: An Example What is the off button can be clicked at any time? What if we want to show how many minutes left to the end of the cycle? Intro | Building Blocks | Advanced What if we want to come back to the same state we left?

25 Abstraction in Statechart Finding Common BehaviorSeparating Independent Regions Composite States Parallel States Intro | Building Blocks | Advanced

26 The State Explosion Problem Let –n: Num of Classes –m: Num of variables (assume equals among classes) Number of possible states = 2 (nm) And... –What if the state space of each variable > 2 –What about association between objects? Class v 1 : {t, f} v 2 : {t, f} v 3 : {t, f}... Class v 1 : {t, f} v 2 : {t, f} v 3 : {t, f}... Class v 1 : {t, f} v 2 : {t, f} v 3 : {t, f}... Intro | Building Blocks | Advanced

27 Composite States Intro | Building Blocks | Advanced

28 Composite + History

29 deep and shallow DiagnosingDiagnosing Diagnostic1 setupsetup Check blood pressure Diagnostic2 Find a vein Draw Blood H* Intro | Building Blocks | Advanced H StopStop pause return return-full Shift ended | clh() clh() – clears the history

30 Completion Transitions Triggered by a completion event –generated automatically when an immediately nested state machine terminatesCommittingCommittingPhase1Phase1 Phase2Phase2 Commit Done completion transition (no trigger) Intro | Building Blocks | Advanced

31 LampFlashing off/ FlashOff FlashOn Triggering Rules Two or more transitions may have the same event trigger –inner transition takes precedence –if no transition is triggered, event is discardedon/on/ Intro | Building Blocks | Advanced

32 Order of Actions: Complex Case Same approach as for the simple caseS1exit:exS1S1exit:exS1 S11exit:exS11S11exit:exS11 S2entry:enS2S2entry:enS2 S21entry:enS21S21entry:enS21 | initS2 E/actE Actions execution sequence: exS11  exS1  actE  enS2  initS2  enS21 Intro | Building Blocks | Advanced

33 Parallel States Sometimes, some aspect of an entity are independent of other aspects single married divorced Martial Staff Member Manager employee Intro | Building Blocks | Advanced

34 Parallel States Annotation Combine multiple simultaneous descriptions StaffMember Manager employee StaffMember Manager employee single married divorced Martial single married divorced Martial Intro | Building Blocks | Advanced

35 Interactions Between Parallel States Intro | Building Blocks | Advanced

36 “Flat” and Parallel Machines Use of Orthogonal Regions No Use of Orthogonal Regions B C E G F AD      (in G)  C,F C,E C,G B,G B,E B,F            Every parallel machine can be transformed into a sequential machine: Intro | Building Blocks | Advanced

37 Transition Forks and Joins For transitions into/out of orthogonal regions: Credit Card verification charging Processing Sent Confirmed shipping Receipt Sent Intro | Building Blocks | Advanced In problem [ok] [not ok] Joinfork

38 Summary Statechart: –State-based modeling –Based on Automatas Statechart building blocks –States –Transitions Advanced Characteristics –Composite States –Parallel States