In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use UML state diagram". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use UML state diagrams.
Brief introduction of UML State Diagram
UML state diagram is a common tool for system analysis, which describes the dynamic behavior of class objects with time by establishing a life cycle model of class objects.
State machine
A state machine is a diagram that shows states and state transitions. Usually a state machine is attached to a class and describes an instance of a class. The state machine contains the sequence of all states of an object of a class during its life cycle and how the object reacts to received events.
The state machine consists of five parts: state, transition, event, activity and action.
UML state diagram
An UML state diagram represents a state machine. It is mainly used to represent the control flow from one state to another.
The UML state diagram consists of nodes that represent states and arrows that represent transitions between states. Several states are connected by one or more transition arrows, and the transition of states is triggered by events. The behavior of model elements can be represented by a path in the UML state diagram along which the state machine performs a series of actions. A simple UML state diagram is as follows:
1. Status
The state is represented by a rectangle with rounded corners, and the icon of the UML state diagram can be divided into three parts: name, internal transition, and nested state.
(1), name. The name represents the name of the state, usually represented by a string. The name of a state should be * in the context of the UML state diagram.
(2) Internal conversion. Internal transitions can include activities or actions that should be performed to enter or exit this state, which will respond to events received by the object, but do not change the state of the object.
(3) nesting UML state diagrams. There are two kinds of states in the UML state diagram: simple state and combined state. A simple state does not contain other states, and a combined state is a state that contains child states. The nested UML state diagram section of the combined state contains the child states of that state.
2. Conversion
The transition is represented by a straight line with arrows, connecting the source state and the destination state, respectively. When the source state receives an event and the monitoring condition is satisfied, the corresponding action is performed and the transition from the source state to the target state is performed at the same time. If the event that triggered the conversion is not marked on the transformation, the conversion occurs automatically.
3. Initial state
The initial state represents the starting position of the UML state diagram, and only one initial state is allowed in a UML state diagram, which is represented by a solid circle.
4. Termination status
The termination state is the termination point of a UML state diagram. It is represented by a hollow circle containing a solid circle.
5. Judgment
The decision is expressed by a small hollow diamond. The workflow branches here according to the value of the guardianship condition.
Status
The states in the UML state diagram include state names, internal transitions, entry and exit actions, simple states, component states (sequential sub-states, concurrent sub-states), and historical states.
Event
An event represents a change of motion that occurs in a particular time or space that can cause a state change. Events are divided into entry events, exit events, action events, signal events, call events, modification events, time events, and delay events.
Conversion
Transition means that when a specific event occurs or some conditions are met, the object in one source state will transition to another state called the target state after completing a certain action.
Transitions in UML state diagrams are usually divided into four types: external transition, internal transition, completion transition and compound transformation. A transition generally includes five parts of information: source state, target state, trigger event, guardianship condition and action.
1. External conversion
An external transition is a transition that changes the state of an object, and it is the most common transition. The external transition is represented by an arrow from the source state to the destination state. The following picture shows a simple state transition of a bathroom on a train. The arrows in the figure are marked with external events that trigger a state transition.
2. Internal conversion
The internal transition has a source state but no destination state, and its transformed state is still itself. Internal transitions are used to model inserts that do not change state, such as help information.
The internal transition is different from the self-transition (that is, the completion transition mentioned later): since the transition is to re-enter the state after leaving the state, it triggers the execution of the entry and exit actions of the state; while the internal transition does not leave the state from beginning to end, so there are no exit or entry events.
3. Complete the conversion
The completion of the transition is called a self-transition, which is called the completion of the transition because it does not indicate that the transition of the trigger event is caused by the completion of the activity in the state.
4. Compound conversion
Composite transformations consist of simple transformations that are combined by branch determination, bifurcation, or engagement. Multi-conditional branch decision is divided into chained and unchained branches, which are shown in the following figure:
5. Trigger event
The triggered event in the UML state diagram is the event that can cause the state transition. Trigger events can be signals, calls, time periods, and so on.
6. Guardianship conditions
The guardianship condition is the condition that must be satisfied to trigger the conversion, and it is a Boolean expression. When the event is triggered, the guardianship condition is assigned. If the Boolean expression is true, the conversion is triggered; otherwise, the conversion is not caused. The guardianship condition can only be assigned once when the trigger event occurs. Multiple transitions derived from a state can have the same trigger event, but each transition must have different monitoring conditions.
7. Action
An action is a set of executable statements or computational processes. Actions can include sending a message to another object, calling an operation, setting a return value, creating and destroying an object, and so on. The action is atomic and uninterruptible.
The whole system can perform multiple actions at the same time. The action is atomic in its control thread, and once it starts execution, it must be executed to the end and cannot interact with actions that are active at the same time.
At this point, I believe you have a deeper understanding of "how to use UML state diagrams". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.