0
00:00:00,630 --> 00:00:02,790
今天我们要讲的是
1
00:00:03,930 --> 00:00:07,420
DDD领域驱动设计浮夸
2
00:00:07,700 --> 00:00:10,590
Eric Evans开了个坏头
3
00:00:14,790 --> 00:00:17,380
在《领域驱动设计》的
4
00:00:18,650 --> 00:00:22,590
前言,也就是这本书的正文
5
00:00:23,750 --> 00:00:23,962
6
00:00:23,962 --> 00:00:26,092
Eric Evans写的第一句话
7
00:00:26,092 --> 00:00:28,647
他就说了这么一段话
8
00:00:28,647 --> 00:00:30,350
9
00:00:30,350 --> 00:00:32,480
翻译起来就是这个意思
10
00:00:33,120 --> 00:00:34,690
意思是什么
11
00:00:35,310 --> 00:00:36,787
至少20年
12
00:00:36,787 --> 00:00:39,496
一直没有人写点什么
13
00:00:39,496 --> 00:00:42,205
关于领域建模设计
14
00:00:42,205 --> 00:00:43,190
没写什么
15
00:00:43,470 --> 00:00:43,803
16
00:00:43,803 --> 00:00:46,803
一直到他这个哲学
17
00:00:46,803 --> 00:00:47,470
18
00:00:48,100 --> 00:00:49,465
暗流
19
00:00:49,465 --> 00:00:51,970
出现,领域驱动设计
20
00:00:53,620 --> 00:00:53,985
21
00:00:53,985 --> 00:00:57,270
这是他写在书上的
22
00:00:57,550 --> 00:00:59,880
他本人写的第一句话
23
00:01:02,590 --> 00:01:04,094
那至少20年
24
00:01:04,094 --> 00:01:09,109
这本书是写于2003年,出版于2003年
25
00:01:09,109 --> 00:01:09,360
26
00:01:09,870 --> 00:01:11,275
按Evans说的
27
00:01:11,275 --> 00:01:12,680
就是
28
00:01:13,640 --> 00:01:16,200
前面20年是
29
00:01:16,200 --> 00:01:18,760
1983年到2002年
30
00:01:20,510 --> 00:01:22,210
几乎没有人写什么
31
00:01:25,290 --> 00:01:26,520
是这样的吗
32
00:01:27,100 --> 00:01:27,313
33
00:01:27,313 --> 00:01:28,594
一想就不是嘛
34
00:01:28,594 --> 00:01:29,234
对不对
35
00:01:29,234 --> 00:01:31,368
否则UML怎么来的
36
00:01:31,368 --> 00:01:33,290
UML就是因为什么
37
00:01:33,700 --> 00:01:37,620
各种各样的建模方法学太多了
38
00:01:38,440 --> 00:01:38,656
39
00:01:38,656 --> 00:01:40,170
不止面向对象的
40
00:01:40,170 --> 00:01:41,900
还有面向过程的
41
00:01:42,270 --> 00:01:44,234
UML里面的活动图
42
00:01:44,234 --> 00:01:45,020
这个就是
43
00:01:45,560 --> 00:01:48,183
改善的是面向过程
44
00:01:48,183 --> 00:01:50,330
包括数据流等等
45
00:01:52,050 --> 00:01:54,518
太多了,才要统一符号
46
00:01:54,518 --> 00:01:55,864
统一表示法嘛
47
00:01:55,864 --> 00:01:56,537
对不对
48
00:01:56,537 --> 00:01:59,230
你看,这是《UML参考手册》上
49
00:01:59,510 --> 00:02:00,980
介绍的历史
50
00:02:01,680 --> 00:02:02,440
另外
51
00:02:03,420 --> 00:02:05,713
只要大家去翻以前的书
52
00:02:05,713 --> 00:02:08,007
介绍这个UML怎么来的
53
00:02:08,007 --> 00:02:10,510
基本上都会有讲这个问题
54
00:02:13,670 --> 00:02:15,256
你看,这里说的
55
00:02:15,256 --> 00:02:16,390
大把的这个
56
00:02:17,010 --> 00:02:18,652
书籍面世
57
00:02:18,652 --> 00:02:18,926
58
00:02:18,926 --> 00:02:22,760
一堆一堆
59
00:02:25,960 --> 00:02:29,270
大家也可以用这些关键词去搜嘛
60
00:02:29,740 --> 00:02:31,492
你到亚马逊也好
61
00:02:31,492 --> 00:02:33,465
到哪个国外的书店
62
00:02:33,465 --> 00:02:37,190
去搜1983到2002年时间段
63
00:02:37,670 --> 00:02:39,030
出了哪些书
64
00:02:39,450 --> 00:02:39,658
65
00:02:39,658 --> 00:02:41,955
如果你要搜论文就更多了
66
00:02:41,955 --> 00:02:42,582
对不对
67
00:02:42,582 --> 00:02:44,670
你光搜书都可以的
68
00:02:48,000 --> 00:02:50,617
下面我们列一些书上的图
69
00:02:50,617 --> 00:02:56,070
你可以把它跟现在的各种DDD文章里面的各种发明对比
70
00:02:56,750 --> 00:02:59,800
看哪个里面的逻辑更复杂
71
00:03:03,170 --> 00:03:03,434
72
00:03:03,434 --> 00:03:05,020
这是90年的
73
00:03:05,300 --> 00:03:06,370
这是
74
00:03:06,850 --> 00:03:08,810
Coad和Yourdon
75
00:03:09,090 --> 00:03:09,730
76
00:03:10,490 --> 00:03:12,950
也就是OOA/OOD方法学
77
00:03:13,420 --> 00:03:15,130
书里面一张类图
78
00:03:16,660 --> 00:03:17,230
79
00:03:20,070 --> 00:03:23,601
你看,这里就把类图画成了若干个主题
80
00:03:23,601 --> 00:03:24,264
对不对
81
00:03:24,264 --> 00:03:24,484
82
00:03:24,484 --> 00:03:26,030
分割成若干主题
83
00:03:30,690 --> 00:03:32,681
这本书有中译本
84
00:03:32,681 --> 00:03:34,672
北大出版社出版的
85
00:03:34,672 --> 00:03:37,660
也是1992年左右翻译的
86
00:03:41,220 --> 00:03:43,810
这个是Rumbaugh
87
00:03:44,190 --> 00:03:44,405
88
00:03:44,405 --> 00:03:50,430
Rumbaugh就是UML三个人里面的一个,1991年的这本书
89
00:03:50,430 --> 00:03:52,797
这个书好像没有中译本
90
00:03:52,797 --> 00:03:54,518
我找了没找到
91
00:03:54,518 --> 00:03:55,810
应该是没有的
92
00:03:56,130 --> 00:03:56,351
93
00:03:56,351 --> 00:03:58,344
你看这里面,类图对吧
94
00:03:58,344 --> 00:03:59,230
这是类图
95
00:04:00,270 --> 00:04:01,440
状态图
96
00:04:02,400 --> 00:04:02,782
97
00:04:02,782 --> 00:04:03,930
状态图
98
00:04:09,440 --> 00:04:11,978
这是92年
99
00:04:11,978 --> 00:04:13,670
这个是
100
00:04:14,060 --> 00:04:14,420
101
00:04:14,420 --> 00:04:15,140
Shaler
102
00:04:15,140 --> 00:04:16,580
还有Mellor
103
00:04:16,580 --> 00:04:19,460
这个应该是
104
00:04:22,750 --> 00:04:23,930
1992年
105
00:04:25,190 --> 00:04:26,620
的方法学
106
00:04:26,900 --> 00:04:29,540
他主要是以这个
107
00:04:29,820 --> 00:04:31,550
类图和状态图
108
00:04:32,060 --> 00:04:35,940
作为主要的建模方法
109
00:04:36,390 --> 00:04:36,638
110
00:04:36,638 --> 00:04:38,871
这是他画的状态图
111
00:04:38,871 --> 00:04:41,104
你看是方框
112
00:04:41,104 --> 00:04:43,090
实际上是状态
113
00:04:44,470 --> 00:04:46,196
你看,这个状态的命名
114
00:04:46,196 --> 00:04:46,580
你看
115
00:04:47,510 --> 00:04:51,220
是现在分词,或者是过去分词
116
00:04:51,590 --> 00:04:52,220
117
00:04:55,950 --> 00:04:59,433
像现在很多各种各样
118
00:04:59,433 --> 00:05:01,175
他也画一个状态图
119
00:05:01,175 --> 00:05:03,134
结果出来是一个动词
120
00:05:03,134 --> 00:05:03,352
121
00:05:03,352 --> 00:05:05,093
甚至有的是名词
122
00:05:05,093 --> 00:05:06,400
那这个瞎搞了
123
00:05:10,320 --> 00:05:11,562
那95年
124
00:05:11,562 --> 00:05:13,550
这个是Coad的这个书
125
00:05:13,550 --> 00:05:17,525
那这个书,英文我就没找着了
126
00:05:17,525 --> 00:05:20,010
我找了一个中译本的
127
00:05:22,630 --> 00:05:25,200
你看,它里面列了很多很多案例
128
00:05:25,480 --> 00:05:28,202
包括怎么样分析的,对不对
129
00:05:28,202 --> 00:05:30,430
你看,这是销售的,对吧
130
00:05:31,950 --> 00:05:33,210
这个书有中译本
131
00:05:33,210 --> 00:05:35,010
大家可以去找来看看
132
00:05:36,430 --> 00:05:36,696
133
00:05:36,696 --> 00:05:37,760
类图
134
00:05:40,760 --> 00:05:41,626
Coad
135
00:05:41,626 --> 00:05:45,960
还有这个很有名的了,彩色建模
136
00:05:45,960 --> 00:05:49,426
里面列了很多领域的类图
137
00:05:49,426 --> 00:05:51,160
序列图等等
138
00:05:53,750 --> 00:05:55,640
这个也有中译本
139
00:05:57,360 --> 00:05:57,654
140
00:05:57,654 --> 00:05:59,421
是我们翻译的
141
00:05:59,421 --> 00:06:00,600
大家可以
142
00:06:01,040 --> 00:06:02,160
找来看看
143
00:06:04,950 --> 00:06:08,240
那前面讲的就是面向对象建模了
144
00:06:09,500 --> 00:06:11,873
如果不限于面向对象的
145
00:06:11,873 --> 00:06:13,060
那就更多了
146
00:06:13,340 --> 00:06:13,730
147
00:06:13,730 --> 00:06:14,900
比如说
148
00:06:15,580 --> 00:06:17,060
这是90年的
149
00:06:17,930 --> 00:06:19,451
实际上更早的都有
150
00:06:19,451 --> 00:06:20,060
因为
151
00:06:20,980 --> 00:06:23,590
像实体关系图,类似的
152
00:06:23,870 --> 00:06:25,225
七十年代就有了
153
00:06:25,225 --> 00:06:25,733
对不对
154
00:06:25,733 --> 00:06:26,580
但是因为
155
00:06:27,180 --> 00:06:27,400
156
00:06:27,400 --> 00:06:28,940
Evans刚才说的是
157
00:06:29,330 --> 00:06:29,525
158
00:06:29,525 --> 00:06:30,700
二十年以来嘛
159
00:06:30,700 --> 00:06:34,420
那就是1983到2002嘛
160
00:06:34,420 --> 00:06:36,770
我们就特地选了这个地方
161
00:06:38,160 --> 00:06:42,420
像90年这个,这个叫Teorey
162
00:06:42,420 --> 00:06:44,550
Teorey这个
163
00:06:45,090 --> 00:06:46,350
这个是
164
00:06:47,610 --> 00:06:50,220
数据库建模,他用的是E/R图
165
00:06:52,830 --> 00:06:54,590
你看,右边这个图
166
00:06:57,930 --> 00:07:00,990
那96年,就是Hay这个
167
00:07:02,420 --> 00:07:04,990
这是也用的是
168
00:07:05,330 --> 00:07:07,140
鸦脚的图
169
00:07:08,200 --> 00:07:11,000
也是E/R图的一个变体
170
00:07:13,290 --> 00:07:14,760
你看,这是一个
171
00:07:15,040 --> 00:07:15,950
开支的
172
00:07:16,410 --> 00:07:16,725
173
00:07:16,725 --> 00:07:18,300
开支的一个
174
00:07:19,070 --> 00:07:22,310
一个领域的模型
175
00:07:24,880 --> 00:07:25,960
这本书
176
00:07:26,240 --> 00:07:26,453
177
00:07:26,453 --> 00:07:28,370
实际上就是以
178
00:07:29,710 --> 00:07:32,040
E/R图来描述的
179
00:07:33,690 --> 00:07:36,630
分析模式的归纳
180
00:07:37,140 --> 00:07:38,816
它出版比分析模式
181
00:07:38,816 --> 00:07:39,188
Martin Fowler
182
00:07:39,188 --> 00:07:41,610
那个《分析模式》要早一点点
183
00:07:41,980 --> 00:07:42,212
184
00:07:42,212 --> 00:07:48,023
Fowler分析模式那本书的序言里面就有提到这个书
185
00:07:48,023 --> 00:07:49,650
但是因为这本书
186
00:07:50,660 --> 00:07:52,182
他不是Fowler写的
187
00:07:52,182 --> 00:07:54,140
没有在这个圈子里面
188
00:07:54,610 --> 00:07:56,650
所以呢,大家都不知道
189
00:07:57,000 --> 00:07:57,910
因为
190
00:07:58,190 --> 00:07:59,263
我们之前说过
191
00:07:59,263 --> 00:08:01,052
他圈子里面互相引用
192
00:08:01,052 --> 00:08:03,020
他只引用自己圈子里面的
193
00:08:04,130 --> 00:08:06,476
圈子外的他不引用
194
00:08:06,476 --> 00:08:07,780
或者说,他会
195
00:08:08,180 --> 00:08:09,142
包装一下
196
00:08:09,142 --> 00:08:12,990
由一个圈子里面的人来包装一下再引用
197
00:08:13,870 --> 00:08:14,986
这种手法
198
00:08:14,986 --> 00:08:18,707
我们之前的视频和文章已经提到过很多次了
199
00:08:18,707 --> 00:08:20,940
大家感兴趣可以找我的文章
200
00:08:24,070 --> 00:08:25,093
前面讲的
201
00:08:25,093 --> 00:08:26,525
不管是面向对象
202
00:08:26,525 --> 00:08:27,344
面向过程
203
00:08:27,344 --> 00:08:29,800
都是说软件开发为目的
204
00:08:30,080 --> 00:08:32,492
如果不限于软件开发
205
00:08:32,492 --> 00:08:36,780
仅仅是对领域做描述的这种领域工程
206
00:08:37,060 --> 00:08:38,800
那就还有更多了
207
00:08:39,970 --> 00:08:42,070
那这方面的话
208
00:08:42,830 --> 00:08:45,254
我就不是很擅长了
209
00:08:45,254 --> 00:08:47,140
但是大家可以去
210
00:08:47,550 --> 00:08:49,550
找这相关的
211
00:08:50,350 --> 00:08:53,436
按照关键词搜相关内容
212
00:08:53,436 --> 00:08:54,840
那我这里就
213
00:08:55,120 --> 00:08:56,570
借花献佛
214
00:09:00,520 --> 00:09:02,143
我就用了一个
215
00:09:02,143 --> 00:09:05,660
我在网络上搜到的一个幻灯片
216
00:09:06,190 --> 00:09:06,475
217
00:09:06,475 --> 00:09:08,190
来展示一下
218
00:09:08,700 --> 00:09:11,087
大家也可以去按这个搜
219
00:09:11,087 --> 00:09:12,740
好几个地方有下载的
220
00:09:13,970 --> 00:09:15,600
你看,他说
221
00:09:16,000 --> 00:09:16,197
222
00:09:16,197 --> 00:09:18,964
80年代初期开始了什么什么什么
223
00:09:18,964 --> 00:09:19,360
224
00:09:19,710 --> 00:09:22,713
提出了什么什么什么
225
00:09:22,713 --> 00:09:24,624
有很多成果
226
00:09:24,624 --> 00:09:27,900
有这个这个这个这个这个
227
00:09:28,580 --> 00:09:29,230
228
00:09:33,690 --> 00:09:34,257
然后呢
229
00:09:34,257 --> 00:09:35,960
下面说这个这个这个
230
00:09:36,780 --> 00:09:37,032
231
00:09:37,032 --> 00:09:39,302
你看这80年代的
232
00:09:39,302 --> 00:09:41,320
80年代提出来的
233
00:09:45,860 --> 00:09:46,910
所以呢
234
00:09:49,470 --> 00:09:50,850
Evans说的
235
00:09:51,600 --> 00:09:53,590
几乎没有人写点什么
236
00:09:53,870 --> 00:09:54,100
237
00:09:54,100 --> 00:09:55,250
这是错的
238
00:09:56,220 --> 00:09:59,020
把前面20年描述成荒漠
239
00:09:59,560 --> 00:10:03,720
为领域驱动设计营造出横空出世的感觉
240
00:10:04,200 --> 00:10:05,760
这是一种夸大
241
00:10:07,320 --> 00:10:10,739
我们前面列出的资料
242
00:10:10,739 --> 00:10:11,050
Evans
243
00:10:11,370 --> 00:10:12,550
没有提到
244
00:10:12,840 --> 00:10:14,570
他唯一提到的一本
245
00:10:14,850 --> 00:10:17,115
就是Martin Fowler的分析模式
246
00:10:17,115 --> 00:10:19,380
那我们前面故意就没有提
247
00:10:22,200 --> 00:10:24,475
到底是一无所知,还是刻意忽略
248
00:10:24,475 --> 00:10:25,700
这就不得而知了
249
00:10:25,700 --> 00:10:27,800
但是我前面已经提到很多次
250
00:10:28,180 --> 00:10:30,866
圈子内的封闭引用
251
00:10:30,866 --> 00:10:32,060
这是一个
252
00:10:32,340 --> 00:10:34,060
很大的问题
253
00:10:39,500 --> 00:10:40,370
那么
254
00:10:40,650 --> 00:10:42,589
我历来的评价是这样
255
00:10:42,589 --> 00:10:45,175
你看,2009年我写的文章
256
00:10:45,175 --> 00:10:47,330
这是发在《程序员》杂志上
257
00:10:48,670 --> 00:10:49,930
我们是
258
00:10:50,460 --> 00:10:52,470
国内最早的
259
00:10:52,750 --> 00:10:53,991
接触到这个
260
00:10:53,991 --> 00:10:57,508
然后引进来,向大家介绍的,包括书什么的
261
00:10:57,508 --> 00:10:59,370
最先也是我们做的嘛
262
00:11:00,960 --> 00:11:01,621
所以呢
263
00:11:01,621 --> 00:11:04,930
你看,我当时说什么,起到了一个什么
264
00:11:06,440 --> 00:11:09,050
拨乱反正的作用,对不对
265
00:11:09,330 --> 00:11:10,300
这个地方
266
00:11:12,570 --> 00:11:15,126
并没有说他是什么伟大的创新
267
00:11:15,126 --> 00:11:16,503
本来就是这样
268
00:11:16,503 --> 00:11:19,060
你看,最开始就是这样的,对吧
269
00:11:19,340 --> 00:11:20,530
后来
270
00:11:20,860 --> 00:11:22,990
受到各种冲击
271
00:11:23,420 --> 00:11:24,968
因为这样比较难
272
00:11:24,968 --> 00:11:30,720
后来就有人去推销各种各样拍脑袋的做法
273
00:11:32,370 --> 00:11:33,950
就把它带偏掉了
274
00:11:34,770 --> 00:11:36,247
包括现在都是一样
275
00:11:36,247 --> 00:11:37,910
很多人就会这个
276
00:11:38,190 --> 00:11:39,170
就会这个
277
00:11:39,640 --> 00:11:41,288
他写面向对象建模
278
00:11:41,288 --> 00:11:44,770
他就写这个,下面这个什么SRP、OCP这个
279
00:11:45,260 --> 00:11:47,026
你让他复杂点,他不会的
280
00:11:47,026 --> 00:11:48,263
他就会念叨这个
281
00:11:48,263 --> 00:11:49,853
以为这个就有用了
282
00:11:49,853 --> 00:11:50,560
没用的
283
00:11:53,400 --> 00:11:55,583
你看,我说的拨乱反正
284
00:11:55,583 --> 00:11:56,020
对吧
285
00:11:57,200 --> 00:11:58,804
本来这没有什么
286
00:11:58,804 --> 00:12:01,812
那为什么近年我就开始批评这个呢
287
00:12:01,812 --> 00:12:04,620
因为到2017或2018左右
288
00:12:05,150 --> 00:12:08,840
突然就被包装成革命性的创造
289
00:12:09,120 --> 00:12:11,161
划时代的洞见
290
00:12:11,161 --> 00:12:14,370
巨人等等,就被包装出来
291
00:12:15,780 --> 00:12:16,830
所以呢
292
00:12:17,450 --> 00:12:19,520
我才会去批评他
0
00:00:01,120 --> 00:00:03,351
Evans的书有没有问题呢
1
00:00:03,351 --> 00:00:07,814
有的,主要问题就是我们前面说过很多遍的
2
00:00:07,814 --> 00:00:09,600
他只有D的知识
3
00:00:09,890 --> 00:00:12,083
然后从D的角度去臆想
4
00:00:12,083 --> 00:00:13,280
ABC的知识
5
00:00:15,580 --> 00:00:17,400
但是呢
6
00:00:18,360 --> 00:00:19,396
如果是低调的
7
00:00:19,396 --> 00:00:20,950
没有故意渲染
8
00:00:22,070 --> 00:00:24,160
那么,也没有必要去批评他
9
00:00:25,950 --> 00:00:29,650
但是如果说,被人有意无意利用
10
00:00:29,930 --> 00:00:31,140
来包装
11
00:00:31,620 --> 00:00:34,480
那这个就有批评的必要了