31
00:01:52,300 --> 00:02:04,300
刚才讲了,活动里面是动作
32
00:02:04,300 --> 00:02:06,300
这个动作
33
00:02:06,300 --> 00:02:09,300
就可以看作活动的一个
34
00:02:09,300 --> 00:02:13,300
里面的实现的一个行为了
35
00:02:16,300 --> 00:02:20,300
在UML的参考手册书里面
36
00:02:20,300 --> 00:02:23,300
强调动作是原子的行为
37
00:02:23,300 --> 00:02:31,300
这个原子怎么理解
38
00:02:31,300 --> 00:02:33,300
按道理来说,理论上
39
00:02:33,300 --> 00:02:36,300
你可以无限拆分的
40
00:02:36,300 --> 00:02:40,300
41
00:02:40,300 --> 00:02:42,300
比如说
42
00:02:44,300 --> 00:02:49,300
我要给你一个参数
43
00:02:49,300 --> 00:02:51,300
比如说,就给你一个字符串
44
00:02:51,300 --> 00:02:54,300
你给我统计这个字符串
45
00:02:54,300 --> 00:02:57,300
有多少个字符,就这么简单
46
00:02:57,300 --> 00:02:58,300
你说这是原子的
47
00:02:58,300 --> 00:03:00,300
但实际上也不是原子的
48
00:03:00,300 --> 00:03:03,300
这里面
49
00:03:03,300 --> 00:03:07,300
它里面也有一大坨实现的代码
50
00:03:07,300 --> 00:03:10,300
你要对这里面还可以再分
51
00:03:12,300 --> 00:03:15,300
你分到后面还可以再分
52
00:03:15,300 --> 00:03:18,300
因为高级语言的一句话
53
00:03:18,300 --> 00:03:22,300
高级语言里面可能就一句话
54
00:03:22,300 --> 00:03:24,300
但实际上你要
55
00:03:24,300 --> 00:03:27,300
用汇编什么的表达
56
00:03:27,300 --> 00:03:29,300
可能怎么样
57
00:03:29,300 --> 00:03:31,300
它还可以再分
58
00:03:31,300 --> 00:03:34,300
理论上可以不断分下去
59
00:03:34,300 --> 00:03:36,300
但是为什么我们叫原子的
60
00:03:36,300 --> 00:03:40,300
在活动的上下文里面
61
00:03:40,300 --> 00:03:44,300
我们对它内部细节不感兴趣了
62
00:03:44,300 --> 00:03:50,300
所以它在我们的活动里面是原子的
63
00:03:50,300 --> 00:03:52,300
不感兴趣
64
00:03:52,300 --> 00:03:54,300
并不代表它里面不能再分了
65
00:03:54,300 --> 00:03:56,300
而是说它对我们的活动来说
66
00:03:56,300 --> 00:03:58,300
是原子的
67
00:03:58,300 --> 00:04:00,300
所以
68
00:04:00,300 --> 00:04:06,300
活动图上面里面有原子动作
69
00:04:06,300 --> 00:04:09,300
就直接在工具栏里面
70
00:04:09,300 --> 00:04:11,300
从工具箱里面放一个动作
71
00:04:11,300 --> 00:04:12,300
直接给它命名
72
00:04:12,300 --> 00:04:14,300
第二种是调用的动作
73
00:04:14,300 --> 00:04:17,300
就是有定义好的活动
74
00:04:17,300 --> 00:04:18,300
然后
75
00:04:18,300 --> 00:04:23,300
把它拖上来变成调用的动作
76
00:04:23,300 --> 00:04:28,300
我们建议尽量不用
77
00:04:28,300 --> 00:04:30,300
原子动作
78
00:04:30,300 --> 00:04:34,300
所有的,我们一律建模成活动
79
00:04:34,300 --> 00:04:38,300
不管大是小
80
00:04:38,300 --> 00:04:41,300
因为你没有办法判断它是大是小
81
00:04:41,300 --> 00:04:43,300
你认为是小的
82
00:04:43,300 --> 00:04:45,300
你本来认为是原子的
83
00:04:45,300 --> 00:04:47,300
后面你发现可能还要分解
84
00:04:47,300 --> 00:04:54,300
或者在这个项目的范围需要
85
00:04:54,300 --> 00:04:56,300
还可以再分解
86
00:04:56,300 --> 00:04:58,300
那怎么办呢
87
00:04:58,300 --> 00:05:02,300
那还不如就直接定义成活动
88
00:05:02,300 --> 00:05:04,300
把它拖上来
89
00:05:04,300 --> 00:05:06,300
然后你需要分解的时候
90
00:05:06,300 --> 00:05:08,300
在这个活动下面你再分解
91
00:05:08,300 --> 00:05:14,300
所以我们尽量就直接变成活动
92
00:05:14,300 --> 00:05:16,300
所以你看刚才我们那个SysML
93
00:05:16,300 --> 00:05:19,300
里面就把
94
00:05:19,300 --> 00:05:21,300
这个
95
00:05:21,300 --> 00:05:26,300
活动就把删掉了
96
00:05:26,300 --> 00:05:27,300
就改成什么
97
00:05:27,300 --> 00:05:29,300
动作的定义
98
00:05:29,300 --> 00:05:33,300
而动作就变成了活动的实例
99
00:05:35,300 --> 00:05:36,300
这两个留一个就行了
100
00:05:36,300 --> 00:05:38,300
不需要两个词
101
00:05:38,300 --> 00:05:41,300
要么留动作、动作定义
102
00:05:41,300 --> 00:05:44,300
把活动改成动作定义
103
00:05:44,300 --> 00:05:45,300
要么就活动
104
00:05:45,300 --> 00:05:46,300
活动实例
105
00:05:46,300 --> 00:05:49,300
动作就不要
106
00:05:49,300 --> 00:05:53,300
这样的话就少一个词
107
00:05:53,300 --> 00:05:54,300
我们说伪创新
108
00:05:54,300 --> 00:05:57,300
我经常批评伪创新喜欢造词
109
00:05:57,300 --> 00:05:59,300
那么SysML
110
00:05:59,300 --> 00:06:01,300
这一次的话应该是
111
00:06:01,300 --> 00:06:04,300
把这个往正确的方向
112
00:06:04,300 --> 00:06:06,300
走了一步
113
00:06:06,300 --> 00:06:08,300
把这个词减下来
114
00:06:08,300 --> 00:06:10,300
动作定义
115
00:06:10,300 --> 00:06:13,300
所以它们之间可以看作是
116
00:06:13,300 --> 00:06:15,300
定义和实例的关系
117
00:06:15,300 --> 00:06:18,300
而这一点的话
118
00:06:18,300 --> 00:06:20,300
之前的UML
119
00:06:20,300 --> 00:06:22,300
的1.x的时候
120
00:06:22,300 --> 00:06:23,300
它没有分的
121
00:06:23,300 --> 00:06:26,300
直接活动,活动下面套活动
122
00:06:26,300 --> 00:06:28,300
活动下面套
123
00:06:28,300 --> 00:06:29,300
到最后
124
00:06:29,300 --> 00:06:31,300
说最小的叫动作
125
00:06:33,300 --> 00:06:34,300
这个
126
00:06:34,300 --> 00:06:38,300
虽然说这个词汇上
127
00:06:38,300 --> 00:06:39,300
多了
128
00:06:39,300 --> 00:06:41,300
这是一个问题
129
00:06:41,300 --> 00:06:43,300
但另外还有一个问题
130
00:06:43,300 --> 00:06:44,300
就是说
131
00:06:44,300 --> 00:06:48,300
它把这个调用和定义
132
00:06:48,300 --> 00:06:50,300
或者实例和定义
133
00:06:50,300 --> 00:06:52,300
把它给混淆了
134
00:06:52,300 --> 00:06:56,300
那混淆的话有什么后果
135
00:06:56,300 --> 00:06:58,300
比如说,我们要表达一个这样的
136
00:06:58,300 --> 00:06:59,300
比如说
137
00:06:59,300 --> 00:07:02,300
假设要表达这样一个过程
138
00:07:02,300 --> 00:07:04,300
比如说
139
00:07:04,300 --> 00:07:05,300
这里先做A
140
00:07:05,300 --> 00:07:06,300
对吧
141
00:07:06,300 --> 00:07:08,300
A之后,做一个判断
142
00:07:08,300 --> 00:07:10,300
如果判断是这样的条件的话
143
00:07:10,300 --> 00:07:11,300
就做B
144
00:07:11,300 --> 00:07:12,300
C、D
145
00:07:12,300 --> 00:07:13,300
如果是这样
146
00:07:13,300 --> 00:07:15,300
就做E、C、F
147
00:07:15,300 --> 00:07:19,300
那你看这里出现了
148
00:07:19,300 --> 00:07:20,300
两个C
149
00:07:20,300 --> 00:07:24,300
这里出现两个C
150
00:07:24,300 --> 00:07:25,300
这一个C
151
00:07:25,300 --> 00:07:26,300
这一个C
152
00:07:26,300 --> 00:07:30,300
153
00:07:32,300 --> 00:07:35,300
假设我们没有办法区分的话
154
00:07:35,300 --> 00:07:39,300
直接用活动本身的定义的话
155
00:07:39,300 --> 00:07:43,300
那么我们就得指向E
156
00:07:43,300 --> 00:07:44,300
然后又指向C
157
00:07:44,300 --> 00:07:46,300
对吧
158
00:07:46,300 --> 00:07:48,300
因为你不能有两个
159
00:07:48,300 --> 00:07:49,300
那指向C之后呢
160
00:07:49,300 --> 00:07:50,300
你还得做一个判断
161
00:07:50,300 --> 00:07:53,300
因为下一步是D还是 F
162
00:07:53,300 --> 00:07:56,300
还要做一个判断
163
00:07:56,300 --> 00:07:58,300
这里再判断这个地方
164
00:07:59,300 --> 00:08:01,300
还得在这里再来一个判断
165
00:08:01,300 --> 00:08:03,300
来决定是D还是F
166
00:08:03,300 --> 00:08:08,300
那现在的话
167
00:08:08,300 --> 00:08:10,300
就相当于把这个实例
168
00:08:10,300 --> 00:08:13,300
把它放进来
169
00:08:13,300 --> 00:08:16,300
你就直接把实例放这里就可以了
170
00:08:16,300 --> 00:08:21,300
相当于C有两个实例
171
00:08:21,300 --> 00:08:24,300
在同一个活动里面