1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
1
00:00:00,100 --> 00:00:02,430
The very last diagram that I want to discuss is
2
00:00:02,430 --> 00:00:05,900
the state transition diagram. The state transition diagram is defined for
3
00:00:05,900 --> 00:00:09,270
each relevant class in the system and basically shows the
4
00:00:09,270 --> 00:00:12,880
possible live history of a given class or object. So what
5
00:00:12,880 --> 00:00:15,090
does it mean to describe the life history? It means
6
00:00:15,090 --> 00:00:18,630
that it describes the possible states of the class as defined
7
00:00:18,630 --> 00:00:21,910
by the values of the class attributes. And it also describes
8
00:00:21,910 --> 00:00:25,710
the events that cause a transition from one state to another.
9
00:00:25,710 --> 00:00:28,800
Finally, it describes the actions that result from a state
10
00:00:28,800 --> 00:00:31,050
change. So if you put all of this together you
11
00:00:31,050 --> 00:00:33,760
can see how this can represent the whole history of
12
00:00:33,760 --> 00:00:36,860
the class, from its creation to its destruction. So let me
13
00:00:36,860 --> 00:00:40,610
discuss the transition diagram in more detail, and also provide
14
00:00:40,610 --> 00:00:43,550
information about the notation used to represent them. We have
15
00:00:43,550 --> 00:00:46,770
states, that are represented by ovals with a name. And
16
00:00:46,770 --> 00:00:51,820
we have transitions marked by the event that triggers the transition.
17
00:00:51,820 --> 00:00:55,500
What transitions indicate is the passage from one state to
18
00:00:55,500 --> 00:00:59,430
another state as the consequence of some external stimuli. Notice
19
00:00:59,430 --> 00:01:01,930
that not all events will cause a state transition. So
20
00:01:01,930 --> 00:01:04,930
for example, some events might be consumed within a single state.
21
00:01:04,930 --> 00:01:06,500
And we'll get to that in a second. But in
22
00:01:06,500 --> 00:01:10,200
most cases, an event will trigger some state transition. Events
23
00:01:10,200 --> 00:01:13,480
may also produce actions and they may also have attributes
24
00:01:13,480 --> 00:01:17,100
which are analogous to parameters in a method call. And Boolean
25
00:01:17,100 --> 00:01:20,830
conditions that guard the state transition that is prevented
26
00:01:20,830 --> 00:01:22,860
from happening in the case the conditions are not
27
00:01:22,860 --> 00:01:26,630
satisfied. States may also be associated with activities and
28
00:01:26,630 --> 00:01:31,450
actions. Specifically, activities are operations performed by an object
29
00:01:31,450 --> 00:01:33,410
when it is in a given state and that
30
00:01:33,410 --> 00:01:36,690
takes time to complete. Actions, conversely, just like the
31
00:01:36,690 --> 00:01:40,270
actions corresponding to an event are instantaneous operations that
32
00:01:40,270 --> 00:01:42,420
are performed by an object. And can be triggered
33
00:01:42,420 --> 00:01:46,050
on entry. So, when the object reaches a given state,
34
00:01:46,050 --> 00:01:48,970
when the object exits that state, and also when a
35
00:01:48,970 --> 00:01:53,240
specific event occurs. And in this case, this notation is
36
00:01:53,240 --> 00:01:55,930
basically a shortcut for any event that will cause a
37
00:01:55,930 --> 00:01:58,840
state transition that will bring the object back into the
38
00:01:58,840 --> 00:02:01,696
same state. Since we have several actions and activities, it
39
00:02:01,696 --> 00:02:04,480
is probably worthwhile clarifyinig the ordering of such actions and
40
00:02:04,480 --> 00:02:07,559
activities. So the way in which these actions and activities
41
00:02:07,559 --> 00:02:10,079
occur is, first of all, we have the actions on the
42
00:02:10,079 --> 00:02:13,737
incoming transition, so this is performed first. Then if there is an
43
00:02:13,737 --> 00:02:17,321
entry action that is the next action that would be performed, then
44
00:02:17,321 --> 00:02:22,370
we have activity and event actions as appropriate. And finally exit actions.
|