AMS2024 10b STM
AMS2024 10b STM
State Machines
(Event-based
behavior)
3
States
▪ A state represents a situation where an invariant
condition holds.
▪ Invariant conditions are the properties that the
system satisfies in every reachable state.
4
Entity Life Cycle
Transition diagrams define two kinds of
constraints on entity life cycles:
▪ The set of allowed states. This is a
static constraint.
▪ The set of legal sequences of these
states. This is a transition
constraint because it involves two
or more states.
5
state machines
▪ Entity Behavior can be modeled as state machines.
▪ In principle, not all entities need to be modeled as state machines.
▪ Transition diagrams are an effective mechanism for defining the
behavior of the instances of some entity types.
▪ However, they are not intended to be the best mechanism in all
cases. This is one reason why some conceptual modeling languages
offer several ways to model behavior.
Conceptual Modeling of Information Systems (chapter 13, page 301)
6
An
example
of a State
Machine
Diagram
http://www.sparxsystems.com/uml_tool_guide/uml_dictionary/statediagram.html 7
States…
▪ The State Machine concept can be used for modeling discrete
behavior through finite state transition systems.
▪ The state machine represents behavior as the state history of
an object in terms of its transitions and states.
▪ The activities that are invoked during the transition, entry, and
exit of the states, are specified along with the associated event
and guard conditions.
▪ A composite state has nested states that can be sequential or
concurrent
8
Simples States and Composite States
There are two types of states
– Simple States
9
State Transitions
▪ A transition is based on: std for a Lamp
– a source state s,
– an event d,
– a target state t.
10
State Transitions
▪ An example of a transition of a rental car is:
– Source state: available
– Trigger: domain event Pick-Up
– Target state: in use
Pick-up
availabl
in use
e
11
State Transitions and Guards
▪ Example of a transition of a rent car with a guard is:
– Source state: available
– Guard: the car is not booked for maintenance
– Trigger: domain event Rental Request
– Target state: rented
▪ The meaning is that:
– when a car is in the state Available
– and the domain event Rental Request occurs,
– if the car is not booked for maintenance
– then the new state of the car is rented.
12
State Transitions
Trigger Target
Conditio Initial
State State
n
Source
State
End
State
16
Pseudostates
▪ Initial state – Represents the first state
that occurs when entering a region. An
initial state must be present in each region.
18
Pseudostates
19
Pseudostates - Junction
Junction
▪ A pseudostate with at least one incoming and one outgoing transition. In general, the
incoming transitions have a trigger, and both the incoming and the outgoing transitions have a
guard.
▪ A junction provides a means to simplify two or more transitions by factoring out their common
parts. For example, a junction can be used to converge multiple incoming transitions into a single
outgoing transition representing a shared transition path.
▪ Conversely, a junction can be used to split an incoming transition into multiple outgoing transition
segments with different guard conditions.
20
Pseudostates - Junction
21
Pseudostates - Choice
Choice e1[c1]
▪ Similar to a junction, but the [c2]
guards of the outgoing transitions
are evaluated once the incoming [c3]
e1[c1]
transitions have produced their
effect.
▪ Choices are considered as
dynamic conditional branches
because the target state is not
known until the operations
associated with the incoming
transitions have been completed.
22
Example: Car rental
23
Detailing states
24
Detailing states
With a Composite
State, “InUse” state
is kept, stressing its
semantics!!!
25
Parallelism
26
States and Behaviours
▪ Behaviours
– entry/…action…
– do/…action…
– exit/…action….
27
State Diagrams as Event-based Behaviour
28
H20
http://media.tiscali.co.uk/images/feeds/hutchinson/ency/c00503.jpg
29
An example …
30
An example …
31