Dynamic Modeling
The dynamic model represents the time-dependent aspects of a system. It is a way of describing how an individual object responds to events, either internal events triggered by other objects or external events triggered by the outside world. The main concepts are:
- State: It is a situation at a particular condition during the lifetime of an object.
- Transition: It is a change in the state.
- Event: It is an occurrence that triggers transitions. Events are generally associated with some actions.
- Action: It is an uninterrupted and atomic computation that occurs due to some event. The execution of some specific task due to some event.
- Concurrency of transitions: It is the parallel changes in the states or simply involves selecting multiple transitions simultaneously.
A state machine models the behavior of an object as it passes through a number of states in its lifetime due to some events as well as the actions occurring due to the events. A state machine is graphically represented through a state transition diagram.
States
State is a situation occurring for a finite time period in the lifetime of an object, in which it fulfils certain conditions, perform 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 differentiate one state from another. A state may or may not have any name.
- Entry/Exit Actions: It denotes the activities performed on entering and on exiting the state.
- Internal Transitions: The change within a state that do not cause a change in the state. Ex. If you are in a running state, and suddenly increases your speed but you are in running state.
- Sub-States: State within state.
Internal 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 final states are pseudo-states, and may not have the parts of a regular state expect 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.
State Transition
A transition denotes a change in the state of an object. If an object is in a certain state when an event occurs, the object may perform certain activities subject to specified conditions and changes the state. In this case, a state-transition is said to have occurred.
The transition gives the relationship between the first state and the new state. A transition is graphically represented by a solid directed arc from the source state to the destination state.
Parts of a Transition
- Source State: The state affected by the transition or simply the state before the transition occurs.
- Event Trigger: The occurrence due to which an object in the source state undergoes a transition if the guard condition is satisfied.
- Guard Condition: A Boolean expression which if true causes a transition on receiving the event trigger. A transition may or may not have a guard condition.
- Action: An uninterrupted and atomic computation that occurs on the source object due to some event.
- Target State: The destination state after completion of transition or simply the state after the transition has occurred.
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 that trigger transitions are written alongside the arc of transition in state diagram.
External and Internal Events
External events are those events that are passed by a user of the system to the objects within the system.
Internal events are those events that can be passed from one object to another object within a system.
Concurrency of Events
Concurrency allows more than one objects to receive events at the same time and more than one activity to be executed simultaneously. Concurrency is identified and represented in the dynamic model.
State Transition Diagram
State transition diagrams or state machines describes the dynamic behavior of a single object. It illustrates the sequences of states that an object goes through in its lifetime, the transitions of the states, the events and condition causing the transition and the responses due to the events.
Example :
Suppose a person is taking a taxi from place X to place Y. The states of the person may be waiting, riding and reached.
Comments
Post a Comment