uml state models u state ode s
play

UML State Models U State ode s Basic State Model - PowerPoint PPT Presentation

Overview UML State Models U State ode s Basic State Model Concepts/Notations Basic State Model Concepts/Notations History Psudostates State Model Exercise 1 State Model Exercise 1 Composite States Eunjee Song State


  1. Overview UML State Models U State ode s  Basic State Model Concepts/Notations  Basic State Model Concepts/Notations  History Psudostates  State Model Exercise 1 State Model Exercise 1  Composite States Eunjee Song  State Modeling Design Studio Dept. of Computer Science  Advanced State Model Topics in UML 2.0 Baylor University y y Some slides adapted from materials in the following sources: UML 2 0 Specification by OMG UML Tutorial by Dr R France and State Model UML 2.0 Specification by OMG, UML Tutorial by Dr. R. France, and State Model Tutorial by Dr. E Toch. Eunjee Song Eunjee Song State Models-1 State Models-2 What’s Missing in Behavior Modeling? Modeling States p : Product : ShooppingCart customer display() getPrice() addProduct (p) checkout () How can we model the state of the shopping How can we model the state of the shopping  cart? In Sequence diagram, we Depends on:  do not really know how the Object state (e.g. created, destroyed)  state of the shopping cart state of the shopping cart Variable assignment  changes. Relation status (i.e. number of items)  Operating methods & processes  History History   Eunjee Song Eunjee Song

  2. The Automata Automata – Mathematical Foundations  An Automata is a 4-tuple:  S,  ,  ,S 0   A machine whose output behavior is not only a direct consequence of the current input, but q p ,  S is a set of states   is an alphabet - finite set of symbols of some past history of its inputs.   is the transition function :  : S    S  Characterized by an internal state which y Given a state and Gi t t d  S 0 is an initial state click represents this past experience. an input, the automata jumps to If the phone is ON, then click S 0 on off a new state clicking will turn it off clicking will turn it off  Many uses: M  Stochastic processes (x, y & z are probabilities)  Formal and natural languages (x, y & z are Formal and nat ral lang ages ( & are If the phone is OFF, then characters) clicking will turn it on  Complex systems (x, y & z are…) p y ( , y ) Eunjee Song Eunjee Song Automata Modeling with Statecharts State Models  A state model specifies the life histories of objects in  A Statechart augments deterministic terms of the sequences of operations that can occur automata making them suitable for automata, making them suitable for in response to external stimuli. specifying behavior of complex systems,  For example, a state model can describe how an object using: using: responds to a request to invoke one of its methods. responds to a request to invoke one of its methods  Visual formalism  A state model consists of state diagrams that each describes how an object responds to external stimuli.  Rich alphabet model p  A state diagram describes behavior in terms of  State Modularity sequences of states that an object can go through in  Parallel behavior response to events . t t  Developed by David Harel (Weizman Inst.) Eunjee Song Eunjee Song State Models-8

  3. Simple Example: Telephone Object Object Behavior - General Model  Typical object lifecycle initial state state initialize initialize I dle I dle dl dl Object Object Handling depends on Handling depends on event specific request type specific request type lift receiver/ get dial caller hangs up / Wait for Wait for Wait for tone di disconnect Request Request Request •When the object is created, it moves into the Idle state. Active Active Active Active void:offHook (); (); Handle Handle Handle Handle Activity that is •If a “lift receiver” event is received the {busy = true; Request Request performed during object moves from the Idle to the Active obj.reqDialtone(); … transition: it state. During the transition the “get dial }; executes executes tone activity is executed. tone” activity is executed. instantaneously •If a “caller hangs up” event occurs when in Active state, the object moves to the Terminate Terminate Idle state and the “disconnect” activity is Object Object Object Object performed during the transition. f d d i h i i Eunjee Song Eunjee Song State Models-9 State Models-10 Object Behavior and State Machines Key Concepts  Reflecting object lifecycle in a state diagram  An event is a significant or noteworthy occurrence at a point in time.  Examples of events: sending a request to invoke a method,  Examples of events: sending a request to invoke a method on on Initialize Initialize termination of an activity. Lamp Lamp Object Object  An event occurs instantaneously in the time scale of an On On application application. Wait for Wait for on/print(”on”) Event Event  A state is a condition of an object during its lifetime.  For example, a student is in the registered state after Handle Handle off off completing course registration. Event Event off  A state is an abstraction of an object’s attribute values and Lamp Lamp links Off Off Off Off  For example, a bank account is in the Overdraft Terminate Terminate Object Object state when the value of its balance attribute is less stop than 0. than 0. Eunjee Song Eunjee Song State Models-11 State Models-12

  4. Key Concepts - 2 Basic UML State Diagram  A transition occurs when an event causes an object to “ top” state top” state change from its current (source) state to a target state. State State Initial Initial  For example, if a student is in the registered state and then  For example, if a student is in the registered state and then state state state state top top drops out of the program then the student is in the “not Event Event registered” state. Ready Ready  The source and target states can be the same.  The source and target states can be the same.  A transition is said to fire when the change from source to Transition Transition target state occurs. stop stop /ctr := 0 /ctr : 0  A guard condition on a transition is a boolean  A guard condition on a transition is a boolean expression that must be true for a transition to fire Done Done Final Final  An activity is a behavior that is executed in response y p Activity Activity ct ct ty ty state state t t t t to an event. stop Eunjee Song Eunjee Song State Models-13 State Models-14 States & Classes Activities Class view State view  When holding the state, State in gathering the component can p created t d Transition perform activities. Order do: gatherItems() do: updateInventory()  Can be continuous, taking a status: {created, sent, status {c eated, se t, in gathering in gathering specific, or unbounded, time received} hasProblems : boolean  Activities within a state are sequential sequential gatherItems() th It () sent created updateInventory()  Activities can be interrupted sendOrder()  There are special types of There are special types of enter: set hasProblems to false received(customer) received(customer) do: init gathering list activities: enter, exit and sendReciept() exit: clean log file in problem is received event classified activities Eunjee Song Eunjee Song Intro | Building Blocks | Advanced

  5. Event Types Transitions ChangeEvent : Occurs when a condition expressed as a boolean  event [guard] / action expression becomes true or when there is a c hange in value of x y some entity. y when condition or true/false(variable)  Examples: when(temperature > 80); when(balance < 0); true(hasError)  SignalEvent : Occurs when an signal is sent or received, where a g g ,  signal is a one-way transmission of information from one object to a target object. Event(param1,param2,…)  Examples: lift receiver; hang-up telephone  TimeEvent : Passage of a specific period of time after a designated  event, or an occurrence of a specified time instance. Passage of time since entry to current state - after (time period) , e.g.,  after (10 secs), after (5 secs since exit of state A) Occurrence of a time instance – when(due-date=Feb 28, 2005, 11pm)  Eunjee Song Eunjee Song State Models-18 Guards (Conditions) Events Examples  Conditional execution of transitions C diti l ti f t iti  Signal Events  guards (Boolean predicates) must be side-effect free  Method calls : received(customer) bid bid [value < 100] /reject [ ] /reject j j created created  Event signals: inventoryReady E ent signals i t R d bid bid [value >= 200] /sell /sell inventoryReady  Time event Happy Happy Selling Selling  interval expiry; p y in gathering tm(3 days), tm(1000 ms)  calendar/clock time; when(11:50) false(hasProblems)  Change Event: Change Event: sent  Change in value of some entity; bid bid [(value >= 100) & (value < 200)] /sell /sell tm(3 days) false(hasProblems); received() () true(hasProblems); true(hasProblems); Unhappy Unhappy in problem is received Eunjee Song Eunjee Song State Models-20

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend