The various constituents of a state diagram.
• State Machine: A state machine depicts the various state of an object that change in response to events during its lifetime. A state refers to the conditions of an object during its existence in memory. Each object is in particular state at any given time and remains in that state until an event occurs. In addition, each object has an initial and final state.
Initial state: - The initial state is the starting stage of an object and is represents as a black circle.
• Final state: - A final state indicates that the execution of the state is complete and is represents as a black circle surrounded with ring.
• Events: - An event is an occurrence that triggers a change of state of an object.
The various type events that act as triggers for object
• Call event: -Signifies the receipt of a message that requests for an operation to be performed.
•Signal event: - Signifies the receipt of a message sent form one object to another. The signal may have attributes that contain the data to be sent to another object.
• Time event: - Represents the passage of time, which is denoted by the keyword, after for ex, after 1 second denotes the occurs after the passage of one second.
•Transitions: - A transition is change of state of an object due to the occurrence of an event.
The table lists the various components that you use to depict transition.
Parts of a transition Description
Source state: - represents the current state of an object.
Event trigger: - signifies an occurrence that may cause a transition in the state of an object.
Guard condition: - indicates a Boolean expression. If the expression evaluates to true, the- transition of the state occurs.
Note: - This path is used only if the text in the brackets is true.
Action: - indicates the reaction of an object in response to an event.
Target state: - indicates the state that an object will acquire after an event occurs.
You can depict the complex behavior of objects by using the advanced features of a state machine that decrease the number of states and transitions associated with an object.
The advanced features of a state machine include:
• Entry and exit actions: - Entry actions are used to specify the actions that an object has to perform when it enters a particular state. You can associate an entry action with an event.
The following figure shows the entry actions associated with the entry events of the parts object.
NOTE- The entry event occurs when the part object enters the new state, out of stock. For this entry event, you can associate an entry action, set record level to true. When the parts are out of stock, the inventory manager can reorder the parts and the state of the parts changes form out of stock to in stock. The entry event reoccurs when the part object enters the new state, In Stock. You can associate an entry action, set reorder level to false, for the entry event.
The following figure shows the exit actions associated with the exit events of the parts object.
NOTE- The exit event occurs when the part object exit the state, in stock. you can associate an exit action, set record level to true, for the exit event. When the parts are out of stock, the inventory manager can reorder the parts and the state of the parts changes form out of stock to in stock. The exit event reoccurs when the part object exit the state, out of Stock. You can associate an exit action, set reorder level to false, for the exit event.
• Activities: - An object does not perform any activities when it is in a particular state. The object waits for an event to occur to transit to another state.
The following figure shows the activities of the document object when it is in the displayed state.
NOTE: - The document object of (HTML) page keeps on refreshing the content. The activity of the HTML document object is to keep refreshing the page while it is in the displayed state. The document will be interrupted from refreshing the page by a click event that opens a new document.
• Internal Transitions: - Internal Transitions are used to handle events without the transition of an object to a new state.
The following figure shows the click event of the document object when it is in the displayed state.
NOTE- : A document object keeps on displaying the same document if an internal hyperlink is clicked.
• Substates: - A Substate is a state that is contained within another state. It is pertinent to note that a state that contains no other substates is called simple state. Conversely, a state that contains substates is called Composite State.
The two types of states that can exist in a Composite state are:
•Sequential substates: - An object is said to be in a sequential substate, When the object simultaneously exits is multiple substates.
The figure shows how to represent the sequential substates within the Working state.
NOTE: - User input triggers the transition from Awaiting to Registering. Activities within Registering transition the GUI into Visualizing. After the third state, the GUI goes back to Awaiting user input.
• Concurrent substates: - An object is said to be in concurrent substates when it exists in two substates at a given time.
The figure shows how to represent the Concurrent substates within the Working state.
NOTE: - Concurrent substates proceed at the same time. A dotted line separates concurrent substate.
• Deferred Events: - Deferred Events are such events that are postponed until an object acquires the state when it can respond to these events.
Submachine: - A machine is a type of state machine that contains multiple states, such that the set of states in the submachine can be used in multiple state machine diagrams. You can represent a submachine as a state machine.
Stubbed and Complex Transitions: - Stubbed transitions cause a change of state of an object from a simple state to a submachine.
You depict a stubbed transition from the following:
A stub state to a simple state.
A simple state to a stub state.