State Machine Model.

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.
Nested state diagrams:Problems with flat state diagram
State Machine Model. C-S 5462 State Machine View describes the dynamic behavior of objects over time –each object is treated in isolation –the view describes.
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.
Use Case Model. C-S 5462 Use case model describes what the user expects the system to do –functional requirements may describe only the functionalities.
State Transition Diagrams
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.
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.
1 CS/CPE 426 Senior Projects Chapter 21: State Machines Chapter 22:Advanced State Machines [Arlow and Neustadt 2005] March 24, 2009.
THE OBJECT-ORIENTED DESIGN WORKFLOW Statechart Diagrams.
Sharif University of Technology Session # 7.  Contents  Systems Analysis and Design  Planning the approach  Asking questions and collecting data 
1 Lab Beginning Analysis and Design 4 Completion of first version of use case diagram initiates the processes of analysis and design. 4 UML provides.
State and Sequence Diagrams Modelling dynamic information So far we have seen: Use Case Diagrams – requirements capture, interface.
CS451 Introduction to Software Engineering Behavioral Modeling.
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.
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.
Behavioral diagrams Lecture p4 T120B pavasario sem.
Object-Oriented Modeling Using UML CS 3331 Section 2.3 of Jia 2003.
1 Modeling interactions and behavior Lecturer Dr. Mai Fadel.
1 A Student Guide to Object- Oriented Development Chapter 7 State Diagrams.
Information System Design IT60105
1 Kyung Hee University Statecharts Spring Kyung Hee University Specifying Objects’ Behaviour  Interaction diagrams show message-passing behaviour.
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.
State Modeling. Introduction A state model describes the sequences of operations that occur in response to external stimuli. As opposed to what the operations.
CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 UML State Diagrams.
Dynamic Models Sequence Diagrams Collaboration Diagrams Activity Diagrams.
States.
CS3773 Software Engineering Lecture 06 UML State Machines.
Interaction Diagram An interaction diagram is a graphical representation of interactions between objects. Sequence diagram: shows the sequence in which.
Sept Ron McFadyen1 Use Cases Introduced by Ivar Jacobson in 1986 literal translation from Swedish ”usage case” Used to capture and describe.
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.
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.
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 5th Edition Copyright © 2015 John Wiley & Sons, Inc. All rights.
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.
Activity Diagram.
Chapter 4: Business Process and Functional Modeling, continued
State Diagram – Advanced Concepts
State Machine Diagram.
TIM 58 Chapter 6, continued: Behavioral Modeling
State Machine Diagrams
Interaction View.
Dynamic Modeling of Banking System Case Study - I
Use Case Model.
Static and Dynamic Modeling Using UML
State Machine Diagrams
UML State Diagrams.
Chapter 8: Modelling Interactions and Behaviour UML Activity Diagram
UML Activity Diagrams & State Charts
UML State machine diagram
States.
Object Oriented System Design
CS/CPE 426 Senior Projects
Chapter 5 SDL - Data 2007, rev. 08 SEG2101 Chapter 5.
Chapter 5 state Modeling
CS/CPE 426 Senior Projects
States.
Software Engineering System Modeling Chapter 5 (Part 1) Dr.Doaa Sami
CS 791Z State Machines & Advanced State Machines
Information Systems Engineering
UML State Diagrams.
Presentation transcript:

State Machine Model

State Machine View Describes the dynamic behavior of objects over time Each object is treated in isolation This view describes events and operations that manipulate the object under discussion The state view of the entire system is described by a collection of state diagrams, one diagram corresponding to each class in the system Objects object C-S 446/546

Main components of a state diagram A collection of states of the object under consideration A collection of actions while entering a state, exiting a state or within a state A collection of transitions between states A collection of events that trigger transitions A collection of conditions (optional) that might constrain firing of transitions States Actions Transitions Events conditions C-S 446/546

State diagram – basic syntax event (EventParams) [guard] / action (ActionParams) initial State name actions entry/ … exit/ … do/ event (params) event (Eparams) / action (Aparams) actions final Unnamed states C-S 446/546

State diagram - semantics There must be exactly one initial state and one or more final states Some state diagrams do not show the final states; in this case, there is an implicit final state when the program terminates A transition between states is represented by the event that triggers the transition Transitions may have guards or conditions under which the transitions fire One One or more C-S 446/546

State diagram – semantics (continued) A state may optionally have a label Every state may have An entry action – executed as soon as the state is entered An exit action – executed just before leaving the state A “do” action – executed while the object is in this state; it may be ongoing action until the object leaves the state C-S 446/546

State diagram for ATM Account Class Check balance (act) Deposit (amount) Check balance (act) Deposit (amount) Transfer (act, amount) [balance > amount] Normal Initial Transfer (act, amount) [balance=amount] Withdraw (amount) [balance > amount] close Withdraw (amount) [balance = amount] State diagram for ATM Account Class Actions associated with transitions are not shown in this diagram C-S 446/546

State – a formal definition A state is a condition in the life of an object during which the object performs an action or waits for some event A state is represented by the collection of attributes and their corresponding values An object after being created must be in at one particular state at any instant Unless otherwise mentioned, an object remains in a state for a finite time UML allows modeling of transient states (states that exist only for a very short and insignificant duration) C-S 446/546

State – a formal definition (continued) A state (directly or indirectly) includes links (instances of associations) connected with the object at that instant A state may be decomposed into concurrent sub-states (AND relationship) A state may be composed using mutually exclusive disjoint sub-states (OR relationship) C-S 446/546

Event – a formal definition A noteworthy occurrence UML manual version 1.5 Something that happens within the system or interacting with the system at an instant Something that has a significant impact on the system Examples sending a signal or data receiving a signal or data making a request for execution a Boolean condition becoming true a timeout condition becoming true C-S 446/546

Four types of events in UML Signal event occurs when an object sends a signal to another object Call event occurs when a method or operation in an object is invoked Change event occurs when a Boolean condition is changed Time event occurs when a time limit has reached Kindergarten-first grade-second grade Job applicaion, interview C-S 446/546

Representation of events Events are represented by unique labels in the diagram Generally, the transitions that are fired by the occurrence of the event are also represented by the same label Change event labels are preceded by the keyword “when” Time event labels are preceded by the keyword “after” C-S 446/546

Generating an Event An event is generated by the runtime system Asking for inputs Producing outputs Execution of a method Transfer control of execution from one object to another (sending messages or receiving messages) Abnormal termination Error handling, exceptions C-S 446/546

Temporal properties of Events An event is considered to be instantaneous Occurrence of an event causes negligible time This time is not included in the modeling Events may have precedence relationships among them In ATM system, “opening an account” precedes “depositing into account” In course registration system, “enrolling a student in a course” can occur only after “checking the prerequisites completed by the student” C-S 446/546

Transition Represents the change of states of an object switch from “Empty balance” to “Positive balance” A transition is an abstraction of an operation The above transition is an abstraction of deposit operation A transition has finite and significant duration Observable time taken to complete deposit operation C-S 446/546

Transition (continued) A transition may have parameters A transition corresponding to the deposit operation will have the “amount” as a parameter A transition is triggered/invoked/fired by the occurrence of an event The transition corresponding to deposit will occur by the event “request for deposit” The transition from “Positive balance” to “Empty balance” occurs by the completion of the operation “withdrawal” C-S 446/546

Transition (continued) A transition may have a guard/condition The transition corresponding to the withdrawal operation will occur only if the balance is greater than or equal to the amount to be withdrawn The condition associated with a transition is always the precondition for the transition and hence must be checked before the transition occurs An event may cause several transitions to fire The event that triggers the transition to move to “Empty balance” state after withdrawal may also cause a message to be sent to the account holder and at the same time may also cause a note to be recorded in the account log C-S 446/546

Example 1 – State of a “Student” name : String id : Integer courses : set of CourseID name = “John” id = 1514601 courses = {CS546, CS742} Class definition The state of a student object : Student name = “John” id = 1514601 courses = {CS546, CS742, CS551} Another state of the student object C-S 446/546

Example 1 – Simplified representation : Student Student courses = {CS546,CS742} courses : set of CourseID : Student courses = {CS546, CS742, CS551} Indicate only those attributes that define change of state C-S 446/546

Example 1 – State diagram for Student class register [#courses < minRequired] / updateCourses() register[#courses < minRequired] / updateCourses() Initial continuing entry/ initializeCourses() register [#courses >= minRequired] / updateCourses() completed graduated [complete Graduation Requirements] C-S 446/546

Exercise 1 The given state diagram for the student class is incomplete. Complete the diagram to include transitions that correspond to withdrawal from a course C-S 446/546

Exercise 2 Complete the state diagram for the Account class in ATM, by including additional states and transitions to allow withdrawals below the available balance. C-S 446/546

Exercise 3 Draw the state diagram for an object that performs login validation as described in the following example. A login subsystem validates first whether a username is the right format. Second, it checks whether the password is in the right format. Third, it checks whether there is an account corresponding to the username. Finally, it verifies whether the username and password match with the existing account. C-S 446/546

Exercise 4 Draw the state diagrams for objects in a simple three-light traffic light control system. C-S 446/546