about summary refs log tree commit diff
path: root/usth/ICT2.7/P2L2 OO Software Engineering and UML Subtitles/33 - State Transition Diagram Example - lang_en_vs5.srt
blob: 6c4c1bf8c117b7aaa38054e98920f8e64913e0a3 (plain) (blame)
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
1
00:00:00,090 --> 00:00:02,850
As usual were going to illustrate these kind of diagrams by

2
00:00:02,850 --> 00:00:06,050
using an example. In particular we are going to describe the state

3
00:00:06,050 --> 00:00:09,330
transition diagram for part of our example, for part of

4
00:00:09,330 --> 00:00:12,640
our course management system. And we're going to focus on the course

5
00:00:12,640 --> 00:00:15,540
offering class. When the class is created, it enters the

6
00:00:15,540 --> 00:00:19,490
initialization state, in which the activity performed is to initialize the

7
00:00:19,490 --> 00:00:22,580
course. At this point, a simple case is the case in

8
00:00:22,580 --> 00:00:25,550
which the class is cancelled, so there is a cancelled event.

9
00:00:25,550 --> 00:00:28,700
And if that happens, the class is simply cancelled. So it

10
00:00:28,700 --> 00:00:31,720
gets into this final state, which is the state cancelled. And

11
00:00:31,720 --> 00:00:35,500
the activity in this case is to notify the registered students.

12
00:00:35,500 --> 00:00:38,580
Obviously if this is the flow there will be no registered students.

13
00:00:38,580 --> 00:00:41,110
However something else can happen when we are in this initial

14
00:00:41,110 --> 00:00:43,930
state. So what can happen is that a student can register, so

15
00:00:43,930 --> 00:00:47,260
in this case the add student event is triggered. And the

16
00:00:47,260 --> 00:00:50,620
corresponding action is to set the count, in this case it would

17
00:00:50,620 --> 00:00:53,270
be the count of students for the course offering, to one. And

18
00:00:53,270 --> 00:00:55,570
there will be a change of state and the course offering will

19
00:00:55,570 --> 00:00:58,870
get into this open state. And the action that will be performed

20
00:00:58,870 --> 00:01:02,260
on entry will be to register the student. At this point more

21
00:01:02,260 --> 00:01:06,920
students may register. So other student events might occur and notice that we

22
00:01:06,920 --> 00:01:10,630
have a curve here that tells us this event will trigger this

23
00:01:10,630 --> 00:01:13,790
transition only if the count is less than 10. So we're assuming

24
00:01:13,790 --> 00:01:16,120
that we're not going to have more than 10 students just for lack

25
00:01:16,120 --> 00:01:19,010
of a better number in our course offering. So if that

26
00:01:19,010 --> 00:01:21,960
happens, if the count is less than ten so then the count

27
00:01:21,960 --> 00:01:25,880
is incremented so the increment count action takes place. And the

28
00:01:25,880 --> 00:01:28,910
system goes back into the open state, and the new student

29
00:01:28,910 --> 00:01:32,100
is registered. Now here we have an interesting transition, because there's

30
00:01:32,100 --> 00:01:35,380
no event triggering the transition, but simply the fact that the

31
00:01:35,380 --> 00:01:37,780
count is equal to 10. So you can imagine this as

32
00:01:37,780 --> 00:01:40,930
being a transition that is always enabled so can always be triggered,

33
00:01:40,930 --> 00:01:43,410
but will be guarded. By the fact that the count has

34
00:01:43,410 --> 00:01:46,750
to be exactly ten. So basically this transition will take place

35
00:01:46,750 --> 00:01:49,800
only when enough students are added, such we get to count

36
00:01:49,800 --> 00:01:52,900
them. Being incremented and being equal to ten and then the transition

37
00:01:52,900 --> 00:01:55,590
will occur. And we will get into the closed state, in

38
00:01:55,590 --> 00:01:59,025
which the class is no longer open because there are enough students

39
00:01:59,025 --> 00:02:01,730
registered. And at this point, what will happen is that the

40
00:02:01,730 --> 00:02:06,320
course will be finalized. So there will be this activity which performs

41
00:02:06,320 --> 00:02:09,699
some operation that is needed to finalize the course. Another possibility

42
00:02:09,699 --> 00:02:12,150
is that when we are in the open state, the course

43
00:02:12,150 --> 00:02:14,680
is cancelled. And if the course is cancelled, in this case,

44
00:02:14,680 --> 00:02:18,320
we go again to the cancel state. But here, the activity

45
00:02:18,320 --> 00:02:21,850
of notifying registered students makes more sense. Because we will have

46
00:02:21,850 --> 00:02:24,960
at least one registered student in this state, and therefore we'll

47
00:02:24,960 --> 00:02:28,190
need to notify such student that the course offering has been

48
00:02:28,190 --> 00:02:31,470
cancelled. Finally, is it also possible also to cancel a course

49
00:02:31,470 --> 00:02:34,050
after it has been closed? And in this case again, the

50
00:02:34,050 --> 00:02:38,040
same thing will happen. The class will reach the cancelled state and

51
00:02:38,040 --> 00:02:40,850
all the students, in this case ten students, that are registered

52
00:02:40,850 --> 00:02:43,730
for the course will be notified that the course has been cancelled.

53
00:02:43,730 --> 00:02:46,100
So, if we look at this state transition diagram, you can

54
00:02:46,100 --> 00:02:49,860
see that it's pretty easy to see what the evolution of objects

55
00:02:49,860 --> 00:02:52,590
of this class can be. How they can go from their initial

56
00:02:52,590 --> 00:02:56,660
state to various final states depending on what are the external events

57
00:02:56,660 --> 00:02:57,750
that reach the system.