Читать книгу Fundamentals of UML. Educational manual - Sholpan Jomartova - Страница 5
CHAPTER № 5
ОглавлениеStatе Dіagram
Brief content:
Internal activity
Activity states
Superstates
Parallel states
State diagram (state machіne dіagrams) – it is a known technique to describe the behavior of the system. In one form or another state diagram there since 1960, and at the dawn of object-oriented programming are used to represent the behavior of the system. In object-oriented state diagram drawn single class to show the behavior of a single object in the course of his life.
The state diagram begins with the state of the object described by the controller. In the diagram this is indicated by a pseudo-primary (іnіtіal pseudostate) which is not a condition, but has an arrow pointing to the initial state. The chart also appear to rule according to which the object moves from one state to another. These rules are represented as a transition – lines connecting state.
Transition (transіtіon) means moving from one state to another. Each transition has a label that consists of three parts:
trigger-ID [protection] / activity.
All of them are optional. Typically, the trigger identifier – Thisis the only event that can cause a change of state. Protection, if specified, is the logical condition that must be satisfied that the transition occurred. Activity – isa behavior of the system during the transition. It can be any behavioral expression. The full form of the trigger identifier can include several events and parameters.
All three parts of the description of the transition is not optional. Skipping activity means that the transition does not occur. Pass protection means that the transition is always carried out if the trigger event occurs. Trigger ID offline rarely, this means that the transition is immediate, as can be seen mainly in states of activity.
When the specific state occurs in the event that this state can be accomplished only one transition. If you have multiple transitions for their protection should be mutually exclusive. If an event occurs, and allowed transitions no event is ignored.
The final state (fіnal state) means that the state machine has finished the work, which causes the removal of the object controller.
Finite state machines can display only those objects that are directly observed or act. When developers talk about objects, they often refer to the state of the object, referring to a combination of all of the data contained in the fields of objects. However, the state diagram of a finite automaton is a more abstract concept of state; the point is that different states require different ways of responding to events.
Internal activity
States can react to events without making the transition from the internal activity (іnternal actіvіtіes), in which case the event protection activity and are placed inside the rectangle state.
Figure 14 shows the state with internal activities of characters and events of assistance that can be seen in text fields editor UІ. Internal activity similar self-transitions (self transіtіon) – atransition that returns in the same state. Syntax internal activity is built on the same logic events, protection and treatment.
Figure 14 also shows the specific activity: the input and output activity. Input activity is performed every time when there is the entrance to the state; Output Activity – whenever the state is exited. However, activity was not initiated by the internal input and output activity; This is the difference between domestic activities and self-transitions.
Figure 14. Internal events shown in dialing text in the text field
Activity states
There are states in which the object shows some activity. Status Searchіng (search) in Figure 15 is such a state of activity (actіvіtu state): Senior Activity denoted DO /; hence the term DO actіvіtu. Once the search is complete, Goes without activity, such as screening of new equipment (Dіsplau New Hardware). If the activity occurs in the course of an event cancellation (cancel) the activity of a DO is interrupted and the object returns to the Hardware Update Wіndow (Update window hardware).
Figure 15. The state with activity
AND DO activity and normal activities are a manifestation of a behavior. The crucial difference between them lies in the fact that the usual activity occur «instantaneously» and can not be interrupted by the usual events, whereas the DO activity can be performed for a limited time and can be interrupted, as shown in Figure 15. The instantaneity for different systems is treated differently; for real-time systems it may take a few machine instructions, and to desktop software could be several seconds.
Superstates
It often happens that several states have common transitions and internal activities. In such cases, they can be converted into a substate (substates), and general behavior in the transfer superstate (superstate), as shown in Figure 16. Without the superstate would have to draw the transition cancel (cancellation) for all three states within the state Enter Connectіon Detaіls (Entry details compounds).
Figure 16. Superstate with nested substates
Parallel states
The states can be divided into several parallel states, launched at the same time. Fig. 17 shows a simple alarm clock, which may include a CD, or radio, and to show either the current time or alarm time.
Options CD / radio and the current time / alarm time are parallel.
Figure 20 also includes state history (hіstoru pseudostate). This means that when the clocks are included, optional radio / CD goes into a state in which there were times when they were off. Arrow emerging from history, showing what state existed initially, when there was no prehistory.
When used state diagrams
State diagrams are good for describing the behavior of a single object in several precedents. But they are not very suitable for describing the behavior characterized by the interaction of multiple objects. So it makes sense, together with diagrams of the use other technologies. For instance, interaction diagrams perfectly describe the behavior of several objects in a single precedent, and activity diagrams are good for showing the basic sequence of several objects in a few precedents.
Figure 17. Parallel states
Developing state diagrams, do not try to draw them to each class of system. This approach is often used for the purpose of formally rigorous completeness, but are almost always a waste of effort. State diagrams is better to apply only for those classes that exhibit interesting behavior when building a state diagram helps to understand how it happens. Many experts believe that the editor UІ and control objects have functionality useful in mapping using state diagrams.
1. State diagrams (finite state machine diagrams) are intended for:
a) showing different systems;
b) showing objects and their messages in a precedent;
c) understanding the functioning of a precedent;
d) describing behavior of an object in course of his involvement in several precedents.
2. Finite state machines are especially useful for showing graphical user interface and real-time devices:
a) yes;
b) no.
3. A nodal point is used to:
a) merge several incoming transitions in one outbound;
b) split one incoming transition into multiple outgoing;
c) a and b;
d) none of the responses is suitable.
4. History state used to restore previous states:
a) yes;
b) no.
5. Uninterrupted operation is performed:
a) during some time, and interrupted operation is performed instantly and can be interrupted;
b) instantly, and interrupted operation is performed during some time and can be interrupted;
c) during some time, can be interrupted, interrupted operation is also performed during some time;
d) similar to interrupted operation during some time; but only interrupted operation can be interrupted.
6. Transitions are shown with directed segments and have additional options:
a) triggering event (optional), guard condition and activity;
b) triggering event, guard condition (optional) and activity;
c) triggering event, guard condition and activity (optional);
d) triggering event, guard condition and activity, use of each of them is and optional and up to developer.
7. Internal transitions lead to execution of entry and exit operations:
a) yes;
b) no.
8. State self transitions lead to execution of entry and exit operations:
a) yes;
s) no.
9. Composite orthogonal state:
a) is divided into regions, and only one region can be active at the same moment of time;
b) is divided into regions, and only one substate can be active at the same moment of time;
c) is divided into regions, and only one substate can be active in each region at the same time;
d) consists of one region, and several substates can be active simultaneously.
10. Composite non-orthogonal state:
a) consists of several regions, and only one region can be active at the same moment of time;
b) is not divided into regions, and only one substate can be active at the same moment of time;
c) is not divided into regions, and several substates can be active at the same moment of time;
d) is divided into regions, and only one substate in each region can be active at the same moment of time.