The state diagram in the UML9 diagram

Source: Internet
Author: User

The state diagram is one of the diagrams of modeling the dynamic aspects of the system in UML, which describes the dynamic behavior of object state over time by establishing the life cycle model of the object. The state of an object in the system is easiest to discover and understand, so the first thing to consider is the flow of control based on the state. Specifically, a state diagram is used to describe the behavior of an instance of a model element, to describe the order of States and actions, not only to show the state of an object's ownership, but also to describe how events affect these states over time.

To understand the state machine, the state machine is a device that records the state of a given moment, can change its state or trigger an action based on a variety of different inputs for each given change, such as various client software, various interactive pages on the web. A state machine consists of the individual states of an object and the transformations that connect them, which can demonstrate state and state transitions, which describe the sequence of states that an object undergoes in response to an event during its life cycle and the response to those events.

A state machine consists of 5 parts: State, transition, event, activity, and action.

A state is a condition in the life cycle of an object, and an object in a particular state must satisfy certain conditions or perform certain actions.

Conversion refers to a relationship between two different states.

Events are things that happen in time and space that make sense to a state machine.

Actions are those atomic operations that can be performed in a state machine, which means that an object cannot be interrupted by another message while it is running, must be executed, cause a change in state, or return a value.

An activity is a non-atomic operation that is performed in a state machine.

Typically a state machine is attached to a class, a use case, or an operation, and describes the dynamic response process of the event they receive. A state machine is always a partial view of an object, collaboration, or use case, which separates the entity from the outside when considering the problem, so it is appropriate to model the local and the detail.

A state diagram is essentially a state machine describes the dynamic behavior of an entity based on an event response, showing how the entity responds to different times based on the current state.   The composition of a state diagram: State, transition, decision, initial state, and terminating state. The following figure is a simple selection of the state diagram, wherein the decision is optional action, with the use of the choice, not to use.


States are used to model the various conditions of an entity in the life cycle, represented in UML by a rounded rectangle, including state names, ingress and egress actions, internal transformations, and nested states.

Transformation in the UML State modeling mechanism, using a straight line with arrows, one end connected to the source state, the arrow pointing to the target State. Transformations can also label options related to this transformation, which means that the conversion occurs automatically if there is no callout.

Judgment: Judging according to the given conditions, and then making different conversions according to different judgment results, the Hollow diamond is judged in UML.

Initial state: Represents the starting position of the state diagram and must have a no-trigger conversion for the output. The initial state can only be used as the source of the transformation, not as a target for conversion. In UML, a state diagram can have only one initial state, represented by a solid circle.

Terminating state: Is the end of the state graph, there can be multiple termination states in the state diagram, and the terminating state cannot have any form of triggering conversion, in order to excite the completion transition on the encapsulation state. Therefore, the terminating state cannot be the source of the transformation, and the terminating state in UML is represented by a solid circle in a hollow circle. In addition, some special state graphs can have no terminating state.

Role of the state diagram:

1. Clearly describes the sequence of transitions between states, and it is easy to see the order in which events are executed.

2. Helps programmers avoid time errors when developing programs.

3. Describes the factors that affect conversions such as events, guardianship conditions, and actions that must be triggered during state transitions, and helps programmers avoid the entry of illegal time in the program.

4. By judging a branch that can better describe the workflow that should occur for different conditions.

Through the understanding of the state diagram, can clearly see the changes between the system state, the impact of the system function to make more accurate analysis. Both the state diagram and the activity diagram are inseparable, and many of the concepts in the state diagram are also applied in the activity diagram, and the two sets will show a clearer system dynamic state,

More complex applications of state diagrams will be explored further in future use.

The state diagram in the UML9 diagram

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.