september 9 2016 uml state diagrams
play

September 9, 2016 UML state diagrams Pieter van den Hombergh - PDF document

September 9, 2016 UML state diagrams Pieter van den Hombergh Fontys Hogeschool voor Techniek en Logistiek September 9, 2016 Contents HOM UML state representation Transition notation UML state representation State chart syntax Composite


  1. September 9, 2016 UML state diagrams Pieter van den Hombergh Fontys Hogeschool voor Techniek en Logistiek September 9, 2016 Contents HOM UML state representation Transition notation UML state representation State chart syntax Composite states State chart syntax Transition notation Composite states HOM/FHTenL September 9, 2016 2/35 UML State representation HOM Uses and application UML state representation In UML state behaviour is modeled with state charts State chart syntax Transition notation (diagrams) or activity diagrams Composite states State charts are mostly used in reactive systems (systems that wait for and react to asynchronous input changes) Activity diagrams are used in systems where activies are a sequential pattern of synchrous activities Pattern matchers and compilers are an other large application area of state diagrams HOM/FHTenL September 9, 2016 3/35 State chart components HOM UML state State: A stable condition that persists for a significant representation period of time (disjoint with other such conditions) State chart syntax Transition notation Composite states Transition: The change of one state into another in practically no time usually initiated by an event. When state remains the same it is a “self transition” HOM/FHTenL September 9, 2016 4/35 1

  2. September 9, 2016 UML state diagrams Statechart components (Cont’d) HOM UML state Event: A time discrete occurrence of interest representation State chart syntax Guard: Conditions that must be met for a transition to Transition notation Composite states be taken Action: Quick operation executed in practically no time establishing a relevant change or result HOM/FHTenL September 9, 2016 5/35 Execution of actions HOM Actions can be executed when: UML state representation A state is entered. Specified with entry: in the state State chart syntax Transition notation container Composite states A transition is made. Specified besides the transition A state is left. Specified with exit: in the state container. HOM/FHTenL September 9, 2016 6/35 Specification of transitions HOM Labelsyntax: eventname [guard] / actionlist UML state representation eventname Name of the event triggering the transition State chart syntax Transition notation guard Boolean expression that must evaluate to Composite states TRUE for the transition to be taken actionlist Dot-comma separated list of actions executed as a result of the transtion taken HOM/FHTenL September 9, 2016 7/35 Initial and terminal pseudo states HOM UML state Are almost, but not quite, states. States with a representation transient character (i.e. not triggered by event). State chart syntax Transition notation Composite states We know the following pseudo states: Initial state : Indicates the initial or default state. The associated transition to must be made unconditionally (no guard). Drawn as filled dot. Terminal state : Indicates destruction of the object (at the outermost level). Drawn as encircled dot. Choice state : Selects the next state dependent on some condition. Used to simplify the diagram by reducing the number of outgoing transitions of a state. HOM/FHTenL September 9, 2016 8/35 2

  3. September 9, 2016 UML state diagrams Composed states HOM UML state A Super state or container state may be composed of representation two or more (sequential) sub states State chart syntax Transition notation Composite states If state machine reaches super state S, consisting of two (sequential) substates S11 and S12, then it reaches either sub state S11 OR sub state S12. If a state is not further composed of other states it is called a leaf state. Group transition: A transition connected to the edge of a composed state (or: non leave state). Incoming: The sub state entered is determined by initial (or: history if present) pseudo state Leaving: The last actual sub state is stored in the history connector (if present at all) HOM/FHTenL September 9, 2016 9/35 flat std example HOM UML state representation State chart syntax Transition notation Composite states HOM/FHTenL September 9, 2016 10/35 Hierarchical std example HOM UML state representation State chart syntax EngineOn EngineO ff Idle Transition notation Composite states EngineRunning Standby CruisingO ff BreakPressed Accel[Break O ff ] Accel[Brake O ff ] resume AutomatedControl NotAccelerating Accelerating Accel Resuming CruiseSpeed Cruise Cruising HOM/FHTenL September 9, 2016 11/35 History pseudo state HOM UML state First time, if no history exists, the connected state is representation initially entered (like the initial pseudo state). State chart syntax Transition notation Later on the last occupied sub state is entered. Two Composite states variants: Shallow history: Applied to the newly entered state only Deep history (with star): Applied to the newly entered state and all its child states HOM/FHTenL September 9, 2016 12/35 3

  4. September 9, 2016 UML state diagrams State machine operation HOM UML state In a state machine the state changes only due to an representation event occurrence State chart syntax Transition notation If an event occurs in a state where an leaving transition Composite states exists with that particular event name next to it, the transition is triggered. A triggered transition is taken only: when no guard is present if a guard is present and the guard conditions are met. When the transition is taken a chain of actions is executed: The actions from action lists associated with the states left (inside out), the transition and the states entered (outside in). Also when the transition is taken the state is changed unless it is a self transition. In that case the state remains the same, but some action can be taken. HOM/FHTenL September 9, 2016 13/35 Order of actions HOM UML state representation State chart syntax Transition notation Composite states HOM/FHTenL September 9, 2016 14/35 Order of actions with direct to inner state HOM With a direct trasition to an inner state, the initial state is UML state representation bypassed. State chart syntax Transition notation Composite states HOM/FHTenL September 9, 2016 15/35 Order of actions with direct to inner state(2) HOM This also applies to diagrams with history states. UML state representation State chart syntax Transition notation Composite states Quiz: Criticize this diagram. HOM/FHTenL September 9, 2016 16/35 4

  5. September 9, 2016 UML state diagrams Recommendations HOM Wrong UML state representation Unlabeled transitions (no event) State chart syntax Transition notation Guard on initial/history action list Composite states State with only incoming transitions only transitions leaving more transitions leaving responding to the same event with no or non mutual exclusive guards Overlapping guard conditions Better not Apply an entry action list and als an initial action list Add an action list to a history state Use the deep history state (it is not clear on lower levels) HOM/FHTenL September 9, 2016 17/35 More UML Modeling HOM Besides statecharts we will use: UML state representation Use Case Diagram/descriptions State chart syntax Transition notation Class Diagram Composite states Sequence Diagram A consistent and coherent set of diagrams and descriptions together form a model of your system. This model helps you to make sure you understand the problems to be solved and the needs to be fulfilled and to make the step towards the implementation smaller. HOM/FHTenL September 9, 2016 18/35 Use case diagram/description HOM UML state Use case representation Depicted by an oval. Each use case has an associated State chart syntax Transition notation description. Described is the interaction of an actor Composite states with the system to obtain some result from the system or to establish a change to the system without revealing the systems internal structure. Actor: Participant from outside the system The ≪ uses ≫ Relation (default) ≪ extend ≫ Relation ≪ includes ≫ Relation HOM/FHTenL September 9, 2016 19/35 Use case description HOM A use case is described in a table, showing: UML state representation Name (as in diagram!) State chart syntax Transition notation Summary Composite states Dependency (extend/include relations) Actors Preconditions (assumptions) Description Alternatives (another or exceptional sequence) Post-conditions (Result) HOM/FHTenL September 9, 2016 20/35 5

Recommend


More recommend