Dynamic Modeling
Dynamic Modeling
State
The state is an abstraction given by the values of the attributes that the object has at
a particular time period. It is a situation occurring for a finite time period in the
lifetime of an object, in which it fulfils certain conditions, performs certain activities,
or waits for certain events to occur. In state transition diagrams, a state is
represented by rounded rectangles.
Parts of a state
Name − A string differentiates one state from another. A state may not have
any name.
Entry/Exit Actions − It denotes the activities performed on entering and on
exiting the state.
Internal Transitions − The changes within a state that do not cause a change in
the state.
Sub–states − States within states.
Initial and Final States
The default starting state of an object is called its initial state. The final state
indicates the completion of execution of the state machine. The initial and the final
states are pseudo-states, and may not have the parts of a regular state except name.
In state transition diagrams, the initial state is represented by a filled black circle. The
final state is represented by a filled black circle encircled within another unfilled
black circle.
Transition
Suppose a person is taking a taxi from place X to place Y. The states of the person
may be: Waiting (waiting for taxi), Riding (he has got a taxi and is travelling in it), and
Reached (he has reached the destination). The following figure depicts the state
transition.
Events
Events are some occurrences that can trigger state transition of an object or a group
of objects. Events have a location in time and space but do not have a time period
associated with it. Events are generally associated with some actions.
Examples of events are mouse click, key press, an interrupt, stack overflow, etc.
Events that trigger transitions are written alongside the arc of transition in state
diagrams.
Example
Considering the example shown in the above figure, the transition from Waiting
state to Riding state takes place when the person gets a taxi. Likewise, the final state
is reached, when he reaches the destination. These two occurrences can be termed
as events Get_Taxi and Reach_Destination. The following figure shows the events in
a state machine.
External and Internal Events
External events are those events that pass from a user of the system to the objects
within the system. For example, mouse click or key−press by the user are external
events.
Internal events are those that pass from one object to another object within a
system. For example, stack overflow, a divide error, etc.
Deferred Events
Deferred events are those which are not immediately handled by the object in the
current state but are lined up in a queue so that they can be handled by the object in
some other state at a later time.
Event Classes
Event class indicates a group of events with common structure and behavior. As with
classes of objects, event classes may also be organized in a hierarchical structure.
Event classes may have attributes associated with them, time being an implicit
attribute. For example, we can consider the events of departure of a flight of an
airline, which we can group into the following class −
Actions
Activity
Activity is an operation upon the states of an object that requires some time period.
They are the ongoing executions within a system that can be interrupted. Activities
are shown in activity diagrams that portray the flow from one activity to another.
Action
Entry action is the action that is executed on entering a state, irrespective of the
transition that led into it.
Likewise, the action that is executed while leaving a state, irrespective of the
transition that led out of it, is called an exit action.
Scenario
There are two primary diagrams that are used for dynamic modelling −
Interaction Diagrams