1
00:00:00,000 --> 00:00:06,260
刚才我们讲了活动图的历史
2
00:00:06,260 --> 00:00:11,460
那我们来看这个活动图
3
00:00:11,460 --> 00:00:15,260
如果用来建模的话怎么用
4
00:00:15,260 --> 00:00:20,100
按照我们前面讲的软件方法的工作流
5
00:00:20,100 --> 00:00:23,500
业务建模、需求、分析、设计
6
00:00:23,500 --> 00:00:26,500
它怎么用
7
00:00:26,500 --> 00:00:29,900
实际上这四个工作流它都可以用
8
00:00:29,900 --> 00:00:33,900
第一个就是业务建模
9
00:00:33,900 --> 00:00:39,900
就是描述外部组织和我们的目标组织
10
00:00:39,900 --> 00:00:41,900
交互的时候
11
00:00:41,900 --> 00:00:44,900
然后各个系统之间怎么协作的
12
00:00:44,900 --> 00:00:51,900
那么系统在序列图上我们是业务工人、业务实体
13
00:00:51,900 --> 00:00:52,900
这样的东西
14
00:00:52,900 --> 00:00:58,900
那么活动图上就以泳道的方式来表示了
15
00:00:58,900 --> 00:01:01,900
当然泳道这个只是一个形式
16
00:01:01,900 --> 00:01:03,900
我们后面会说到,就是说
17
00:01:03,900 --> 00:01:10,900
活动图上我们可以把这个活动分配到某个块
18
00:01:10,900 --> 00:01:14,900
某个类或某个块的操作里面去
19
00:01:14,900 --> 00:01:20,900
成为那个类的操作的一个实现方式
20
00:01:20,900 --> 00:01:23,900
那这两个就绑定起来了
21
00:01:23,900 --> 00:01:27,900
表现在这个图上就是泳道的方式
22
00:01:27,900 --> 00:01:30,900
系统一,系统二这样
23
00:01:30,900 --> 00:01:31,900
但是呢
24
00:01:31,900 --> 00:01:33,900
EA在活动图上
25
00:01:33,900 --> 00:01:35,900
它没有
26
00:01:35,900 --> 00:01:38,900
这应该可以分很多栏的
27
00:01:38,900 --> 00:01:41,900
上面可以搞一个大的,目标组织这样的
28
00:01:41,900 --> 00:01:46,900
目标组织这个,单独起一个大的一栏
29
00:01:46,900 --> 00:01:47,900
没有
30
00:01:47,900 --> 00:01:50,900
你看刚才那个BPMN这里就有,对吧
31
00:01:50,900 --> 00:01:52,900
这里你看
32
00:01:52,900 --> 00:01:57,900
亚马公司这,是仓库部门、财务部门、销售部门
33
00:01:57,900 --> 00:01:58,900
对吧
34
00:01:58,900 --> 00:02:01,900
EA这个活动图的话
35
00:02:01,900 --> 00:02:03,900
我不知道怎么画,没画出来
36
00:02:03,900 --> 00:02:05,900
这个
37
00:02:05,900 --> 00:02:09,900
再捉摸捉摸
38
00:02:09,900 --> 00:02:12,900
也可能它就没有这个
39
00:02:12,900 --> 00:02:15,900
这个功能
40
00:02:15,900 --> 00:02:19,900
业务建模我们知道
41
00:02:19,900 --> 00:02:23,900
包括后面讲的系统的需求等等
42
00:02:23,900 --> 00:02:27,900
里面我们往往用用例
43
00:02:27,900 --> 00:02:31,900
来描述这个价值
44
00:02:31,900 --> 00:02:35,900
但是我们知道用例
45
00:02:35,900 --> 00:02:37,900
这个概念
46
00:02:37,900 --> 00:02:39,900
它是一个什么
47
00:02:39,900 --> 00:02:42,900
从卖的角度去看问题的
48
00:02:42,900 --> 00:02:47,900
从卖的角度去把一些
49
00:02:47,900 --> 00:02:49,900
交互的集合怎么样
50
00:02:49,900 --> 00:02:51,900
把它打包在一起的
51
00:02:51,900 --> 00:02:54,900
所以呢,往往一个用例背后
52
00:02:54,900 --> 00:02:59,900
它会包含着多个回合的这种交互
53
00:02:59,900 --> 00:03:02,900
比如说,这个业务用例
54
00:03:02,900 --> 00:03:05,900
外部组织这样一做
55
00:03:05,900 --> 00:03:06,900
这边搞搞搞
56
00:03:06,900 --> 00:03:09,900
这时候返回一个东西到外部组织这里
57
00:03:09,900 --> 00:03:14,900
然后外部组织这里又做第二个
58
00:03:14,900 --> 00:03:16,900
进来,这边又这样
59
00:03:16,900 --> 00:03:18,900
也就是说,它为了
60
00:03:18,900 --> 00:03:22,900
达到一个它想要的价值
61
00:03:22,900 --> 00:03:28,900
它要和我们这个组织,和我们内部交互很多次
62
00:03:28,900 --> 00:03:33,900
就像,比如说,我们《软件方法》里面提到一个办证嘛
63
00:03:33,900 --> 00:03:33,900
对吧
64
00:03:33,900 --> 00:03:35,900
你办证
65
00:03:35,900 --> 00:03:37,900
你到工商去办证
66
00:03:37,900 --> 00:03:41,900
那么你首先要先提交申请
67
00:03:41,900 --> 00:03:43,900
提交完了
68
00:03:43,900 --> 00:03:45,900
里面有个流程
69
00:03:45,900 --> 00:03:48,900
过了很多天
70
00:03:48,900 --> 00:03:52,900
然后人家返回给你说,可以来
71
00:03:52,900 --> 00:03:54,900
正式来办了
72
00:03:54,900 --> 00:03:59,900
你再拿上材料又到工商去办
73
00:03:59,900 --> 00:04:02,900
也就是说,你要和工商打交道
74
00:04:02,900 --> 00:04:04,900
至少打两次交道
75
00:04:04,900 --> 00:04:08,900
但你不能说一次交道是一个用例,不是的
76
00:04:08,900 --> 00:04:11,900
因为你对它的期望
77
00:04:12,900 --> 00:04:14,900
就是把证办下来
78
00:04:14,900 --> 00:04:16,900
你证办不下来
79
00:04:16,900 --> 00:04:18,900
这个意义都不大
80
00:04:18,900 --> 00:04:20,900
你前面的做了白做
81
00:04:20,900 --> 00:04:23,900
那系统用例也是一样的
82
00:04:23,900 --> 00:04:25,900
比如说,拿取款机为例
83
00:04:25,900 --> 00:04:27,900
你为了取现金
84
00:04:27,900 --> 00:04:31,900
你要和这个取款机交互很多次
85
00:04:31,900 --> 00:04:33,900
才能取到现金
86
00:04:33,900 --> 00:04:39,900
所以我们这个活动图上面的话
87
00:04:40,900 --> 00:04:42,900
如果要描述这个用例的话
88
00:04:42,900 --> 00:04:46,900
它往往是要多次交互,多个活动
89
00:04:46,900 --> 00:04:49,900
组织起来的
90
00:04:49,900 --> 00:04:55,900
业务建模
91
00:04:55,900 --> 00:04:59,900
外部组织,目标组织里面多个系统
92
00:04:59,900 --> 00:05:01,900
需求呢
93
00:05:01,900 --> 00:05:03,900
跟业务建模差不多
94
00:05:03,900 --> 00:05:06,900
就是把目标系统放这里
95
00:05:06,900 --> 00:05:08,900
外部系统
96
00:05:08,900 --> 00:05:10,900
做什么
97
00:05:10,900 --> 00:05:14,900
也同样有多次的交互的回合
98
00:05:14,900 --> 00:05:20,900
那么这里面经常会有一个问题
99
00:05:20,900 --> 00:05:22,900
就是说
100
00:05:22,900 --> 00:05:25,900
假设我用活动图来描述需求的话
101
00:05:25,900 --> 00:05:29,900
应该描述到多细的问题
102
00:05:29,900 --> 00:05:36,900
因为有的同学经常会这样问
103
00:05:36,900 --> 00:05:38,900
有的同学会这样问
104
00:05:38,900 --> 00:05:45,900
假设我的系统是用面向过程的方式来做
105
00:05:45,900 --> 00:05:46,900
来思考
106
00:05:46,900 --> 00:05:48,900
我没有什么对象
107
00:05:48,900 --> 00:05:49,900
我就是过程
108
00:05:49,900 --> 00:05:53,900
对我来说就不分什么对象
109
00:05:53,900 --> 00:05:55,900
我就是过程
110
00:05:55,900 --> 00:05:58,900
或者说,我所有的过程
111
00:05:58,900 --> 00:06:02,900
我都看作“系统”对象的一个操作
112
00:06:03,900 --> 00:06:06,900
所有的都是我这个系统的操作
113
00:06:06,900 --> 00:06:10,900
那既然是系统的操作
114
00:06:10,900 --> 00:06:13,900
系统作为一个整体的操作
115
00:06:13,900 --> 00:06:15,900
那不都是需求吗?对不对?
116
00:06:15,900 --> 00:06:20,900
是这样
117
00:06:20,900 --> 00:06:23,900
需求是系统作为一个整体的表现
118
00:06:23,900 --> 00:06:29,900
但不代表说系统作为整体的表现
119
00:06:29,900 --> 00:06:31,900
一定是需求
120
00:06:32,900 --> 00:06:33,900
这地方一定要注意
121
00:06:33,900 --> 00:06:35,900
需求是整体的
122
00:06:35,900 --> 00:06:37,900
系统作为整体的一个表现
123
00:06:37,900 --> 00:06:39,900
但系统作为整体的表现不一定是需求
124
00:06:39,900 --> 00:06:40,900
很简单
125
00:06:40,900 --> 00:06:41,900
比如说,我们举个例子
126
00:06:41,900 --> 00:06:45,900
就像我们刚才讲的那个
127
00:06:45,900 --> 00:06:49,900
假设我系统就把所有的代码团在一起
128
00:06:49,900 --> 00:06:52,900
我也不分什么模块,也不分了
129
00:06:52,900 --> 00:06:54,900
所有代码团在一起
130
00:06:54,900 --> 00:07:01,900
假设我系统是不分任何模块
131
00:07:01,900 --> 00:07:03,900
所有代码团在一起的话
132
00:07:03,900 --> 00:07:05,900
那里面的某一行代码算不算需求
133
00:07:05,900 --> 00:07:07,900
不算的
134
00:07:07,900 --> 00:07:10,900
倒过来是不对的
135
00:07:10,900 --> 00:07:12,900
因为我们需求是什么
136
00:07:12,900 --> 00:07:14,900
不这样不行
137
00:07:14,900 --> 00:07:19,900
你代码不这样写可以吗,是可以的
138
00:07:19,900 --> 00:07:24,900
那什么是不这样不行的
139
00:07:24,900 --> 00:07:26,900
就是功能和性能
140
00:07:26,900 --> 00:07:28,900
就是说在涉众眼里看来,不这样不行的
141
00:07:28,900 --> 00:07:31,900
所以这里面怎么样和分析
142
00:07:31,900 --> 00:07:35,900
把它分界线分清楚
143
00:07:35,900 --> 00:07:37,900
要点还是不这样不行
144
00:07:37,900 --> 00:07:40,900
就是说,你不这样分解可以吗?
145
00:07:40,900 --> 00:07:43,900
比如说,这里为什么分两个活动
146
00:07:43,900 --> 00:07:45,900
不分可以吗?
147
00:07:45,900 --> 00:07:47,900
如果说不分也可以
148
00:07:47,900 --> 00:07:51,900
照样可以满足涉众利益
149
00:07:51,900 --> 00:07:53,900
那这两个就不用分了
150
00:07:53,900 --> 00:07:56,900
一个活动就可以了
151
00:07:56,900 --> 00:07:57,900
如果说不分不行
152
00:07:57,900 --> 00:07:59,900
因为里面的规则
153
00:07:59,900 --> 00:08:02,900
我们业务规则本身就要求
154
00:08:02,900 --> 00:08:06,900
必须要这样分
155
00:08:06,900 --> 00:08:09,900
不分就没有办法满足我们的业务规则
156
00:08:09,900 --> 00:08:11,900
那就可以
157
00:08:11,900 --> 00:08:15,900
就是说
158
00:08:15,900 --> 00:08:17,900
分析
159
00:08:17,900 --> 00:08:19,900
如果是面向过程的话
160
00:08:19,900 --> 00:08:21,900
分析比需求
161
00:08:21,900 --> 00:08:23,900
需要分得更细的
162
00:08:24,900 --> 00:08:26,900
那么判断什么是需求
163
00:08:26,900 --> 00:08:28,900
什么是分析
164
00:08:28,900 --> 00:08:30,900
就要看
165
00:08:30,900 --> 00:08:32,900
什么是不这样不行
166
00:08:32,900 --> 00:08:35,900
分析是这样也行的
167
00:08:35,900 --> 00:08:39,900
因为分解有很多种分解
168
00:08:39,900 --> 00:08:41,900
比如,同样一个大的
169
00:08:41,900 --> 00:08:43,900
大的一个活动
170
00:08:43,900 --> 00:08:46,900
你可以分成两个,分成三个
171
00:08:46,900 --> 00:08:49,900
三个里面还可以再分,对不对
172
00:08:49,900 --> 00:08:52,900
理论上你可以无限地分下去
173
00:08:54,900 --> 00:08:57,900
但是哪些是你要画出来的
174
00:08:57,900 --> 00:08:59,900
表达出来的
175
00:08:59,900 --> 00:09:03,900
那么这里的判断标准就是
176
00:09:03,900 --> 00:09:05,900
不这样不行
177
00:09:05,900 --> 00:09:07,900
那分析就是
178
00:09:07,900 --> 00:09:09,900
结合
179
00:09:09,900 --> 00:09:11,900
因为你怎么分解
180
00:09:11,900 --> 00:09:14,900
到底分解成几个活动
181
00:09:14,900 --> 00:09:17,900
每一个活动的输入输出参数
182
00:09:17,900 --> 00:09:19,900
是什么类型
183
00:09:19,900 --> 00:09:22,900
是跟你的静态模型
184
00:09:22,900 --> 00:09:25,900
也就是类模型或者数据模型是相关的
185
00:09:25,900 --> 00:09:29,900
那分析就要结合我们的类模型
186
00:09:29,900 --> 00:09:31,900
或者说数据模型
187
00:09:31,900 --> 00:09:34,900
来决定
188
00:09:34,900 --> 00:09:37,900
怎么样的分解
189
00:09:37,900 --> 00:09:39,900
是比较合理的
190
00:09:39,900 --> 00:09:41,900
但这个跟需求没关系
191
00:09:41,900 --> 00:09:43,900
需求要的是功能和性能
192
00:09:43,900 --> 00:09:47,900
也就是说,在满足需求的情况下
193
00:09:47,900 --> 00:09:49,900
结合上这个
194
00:09:49,900 --> 00:09:51,900
合理的数据模型或类模型
195
00:09:51,900 --> 00:09:55,900
挑出一个最佳的
196
00:09:55,900 --> 00:09:57,900
子活动的分解
197
00:09:57,900 --> 00:09:59,900
这个是分析
198
00:09:59,900 --> 00:10:03,900
设计
199
00:10:03,900 --> 00:10:05,900
就是结合
200
00:10:05,900 --> 00:10:07,900
语言、平台的实现
201
00:10:07,900 --> 00:10:12,900
类模型和数据模型
202
00:10:12,900 --> 00:10:14,900
这个映射是一样的
203
00:10:14,900 --> 00:10:15,900
就不用说了
204
00:10:15,900 --> 00:10:17,900
我们看逻辑上
205
00:10:17,900 --> 00:10:19,900
逻辑上,活动图能用来做什么
206
00:10:19,900 --> 00:10:21,900
活动图的话
207
00:10:21,900 --> 00:10:24,900
最常见的就是
208
00:10:24,900 --> 00:10:26,900
我们把它当流程图用
209
00:10:26,900 --> 00:10:29,900
就在类的操作下面
210
00:10:29,900 --> 00:10:31,900
绑定一个活动图
211
00:10:31,900 --> 00:10:34,900
比如说,我们类的操作绑定这样一个活动图
212
00:10:34,900 --> 00:10:36,900
操作1,绑定这样一个活动图
213
00:10:36,900 --> 00:10:38,900
那这个图画完之后
214
00:10:38,900 --> 00:10:39,900
你绑定到这个操作
215
00:10:39,900 --> 00:10:41,900
生成代码的时候
216
00:10:41,900 --> 00:10:43,900
它会生成类似这样的代码
217
00:10:43,900 --> 00:10:45,900
这个代码就是生成的
218
00:10:45,900 --> 00:10:48,900
它跟我们的活动图是
219
00:10:48,900 --> 00:10:50,900
对应的
220
00:10:50,900 --> 00:10:55,900
这是面向对象
221
00:10:55,900 --> 00:10:57,900
包括面向过程
222
00:10:57,900 --> 00:10:59,900
都一样
223
00:10:59,900 --> 00:11:01,900
我们把它当成一个流程图来用
224
00:11:01,900 --> 00:11:04,900
其中控制流是焦点
225
00:11:04,900 --> 00:11:06,900
控制流
226
00:11:06,900 --> 00:11:08,900
如果这样,否则这样
227
00:11:08,900 --> 00:11:10,900
if else 控制流
228
00:11:12,900 --> 00:11:14,900
另外一个
229
00:11:14,900 --> 00:11:16,900
用处就是
230
00:11:16,900 --> 00:11:18,900
把它当成数据流是焦点的
231
00:11:18,900 --> 00:11:22,900
就是
232
00:11:22,900 --> 00:11:24,900
现在另外一个流派
233
00:11:24,900 --> 00:11:26,900
函数式编程的思想
234
00:11:26,900 --> 00:11:28,900
把我们的
235
00:11:28,900 --> 00:11:32,900
系统看作是由若干函数
236
00:11:32,900 --> 00:11:34,900
来
237
00:11:34,900 --> 00:11:36,900
组装而成的
238
00:11:38,900 --> 00:11:40,900
这跟我们前面讲的
239
00:11:40,900 --> 00:11:42,900
数据的加工机一样
240
00:11:42,900 --> 00:11:44,900
进来
241
00:11:44,900 --> 00:11:46,900
出去
242
00:11:46,900 --> 00:11:48,900
变成
243
00:11:48,900 --> 00:11:49,900
文本的代码
244
00:11:49,900 --> 00:11:50,900
类似这样的
245
00:11:50,900 --> 00:11:51,900
管道一样的
246
00:11:51,900 --> 00:11:52,900
函数1
247
00:11:52,900 --> 00:11:54,900
函数2
248
00:11:54,900 --> 00:11:56,900
出来,函数3
249
00:11:56,900 --> 00:11:58,900
它跟这个是非常相像和对应的
250
00:11:58,900 --> 00:12:03,900
当然活动图本身只要能够解决好
251
00:12:03,900 --> 00:12:07,900
它本来是面向过程的
252
00:12:07,900 --> 00:12:09,900
你要变成面向函数的
253
00:12:09,900 --> 00:12:13,900
要解决好的一个,递归
254
00:12:13,900 --> 00:12:17,900
你怎么
255
00:12:17,900 --> 00:12:18,900
能够
256
00:12:18,900 --> 00:12:20,900
调用自己
257
00:12:20,900 --> 00:12:23,900
那这个的话
258
00:12:23,900 --> 00:12:25,900
可以解决
259
00:12:25,900 --> 00:12:31,900
把我自己的输出
260
00:12:31,900 --> 00:12:33,900
变成我自己的输入
261
00:12:36,900 --> 00:12:38,900
那第二个
262
00:12:38,900 --> 00:12:40,900
就是高阶函数
263
00:12:40,900 --> 00:12:42,900
就是把函数
264
00:12:42,900 --> 00:12:44,900
作为参数
265
00:12:44,900 --> 00:12:46,900
把函数作为另外一个函数的参数
266
00:12:46,900 --> 00:12:51,900
这个也可以解决
267
00:12:51,900 --> 00:12:53,900
就是说
268
00:12:53,900 --> 00:12:54,900
我们
269
00:12:54,900 --> 00:12:56,900
活动图有一个
270
00:12:56,900 --> 00:12:58,900
把活动当作块
271
00:12:58,900 --> 00:13:00,900
在SysML里面
272
00:13:00,900 --> 00:13:02,900
活动作为块来使用
273
00:13:04,900 --> 00:13:06,900
那块本身
274
00:13:06,900 --> 00:13:08,900
就是一个
275
00:13:08,900 --> 00:13:10,900
类
276
00:13:10,900 --> 00:13:11,900
它可以作为一个
277
00:13:11,900 --> 00:13:13,900
传递的参数
278
00:13:13,900 --> 00:13:17,900
所以活动图目前是
279
00:13:17,900 --> 00:13:19,900
函数式
280
00:13:19,900 --> 00:13:20,900
编程
281
00:13:20,900 --> 00:13:22,900
如果说有什么图形化
282
00:13:22,900 --> 00:13:24,900
表示的话
283
00:13:24,900 --> 00:13:25,900
活动图
284
00:13:25,900 --> 00:13:26,900
目前是
285
00:13:26,900 --> 00:13:28,900
为数不多的一个选择
286
00:13:31,900 --> 00:13:33,900
这是设计的
287
00:13:33,900 --> 00:13:37,900
工作流