架构漫谈是由资深架构师王概凯Kevin执笔的系列专栏,专栏将会以Kevin的架构经验为基础,逐步讨论什么是架构、怎样做好架构、软件架构如何落地、如何写好程序等问题。专栏的目的是希望能抛出一些观点,并引发大家思考,如果你有感触或者新的感悟,欢迎联系专栏负责人Gary(微信greenguolei)深聊。
本文是漫谈架构专栏的第一篇,作者将会通过类比的方式来介绍什么是架构以及为什么会产生架构。
缘起
一直以来,在软件行业,对于什么是架构,都有很多的争论,每个人都有自己的理解。甚至于很多架构师一说架构,就开始谈论什么应用架构、硬件架构、数据架构等等。我曾经也到处寻找过架构的定义,请教过很多人,结果发现,没有大家都认可的定义。套用一句关于big data流行的笑话,放在架构上也适用:
Architecture is like teenage sex,everybody talks about it,nobody really knows what is it。
事实上,架构在软件发明时的N多年以前,就已经存在了,这个词最早是跟随着建筑出现的。所以,我觉得有必要从源头开始,把架构这个概念先讨论清楚,只有这样,软件行业架构的讨论才有意义。
什么是架构?
架构的英文是Architecture,在Wikipedia上,架构是这样定义的:
Architecture (Latin architectura, from the Greek ?ρχιτ?κτων arkhitekton"architect", from ?ρχι- "chief" and τ?κτων "builder") is both the process and the product of planning, designing, and constructing buildings and other physical structures。
从这个定义上看,架构好像是一个过程,也不是很清晰。为了讲清楚这个问题,我们先来看看为什么会产生架构。
为什么会产生架构?
想象一下,在最早期,每个人都完全独立生活,衣、食、住、行等等全部都自己搞定,整个人类都是独立的个体,不相往来。为了解决人类的延续的问题,自然而然就有男女群居出现,这个时候就出现了分工了,男性和女性所做的事情就会有一定的分工,可是人每天生活的基本需求没有发生变化,还是衣食住行等生活必须品。
北京富婆包养
http://www.369gsh.com/gushi/ http://www.369gsh.com/gushi/dongwugushi/ http://www.369gsh.com/gushi/chengyu/ http://www.369gsh.com/gushi/yuyangushi/ http://www.369gsh.com/gushi/tonghuagushi/ http://www.369gsh.com/gushi/lishigushi/ http://www.369gsh.com/gushi/mingrengushi/
http://www.369gsh.com/gushi/minjiangushi/ http://www.369gsh.com/gushi/chengyu/10719.html http://www.369gsh.com/gushi/chengyu/10718.html http://www.369gsh.com/gushi/chengyu/10717.html http://www.369gsh.com/gushi/chengyu/10715.html http://www.369gsh.com/gushi/chengyu/10714.html
http://www.369gsh.com/gushi/chengyu/10713.html http://www.369gsh.com/gushi/chengyu/10712.html http://www.369gsh.com/gushi/chengyu/10711.html http://www.369gsh.com/gushi/chengyu/10710.html http://www.369gsh.com/gushi/chengyu/10709.html http://www.369gsh.com/gushi/chengyu/10708.html
http://www.369gsh.com/gushi/chengyu/10707.html http://www.369gsh.com/gushi/chengyu/10706.html http://www.369gsh.com/gushi/chengyu/10705.html http://www.369gsh.com/gushi/chengyu/10704.html http://www.369gsh.com/gushi/chengyu/10700.html http://www.369gsh.com/gushi/chengyu/10699.html
http://www.369gsh.com/gushi/chengyu/10698.html http://www.369gsh.com/gushi/chengyu/10697.html http://www.369gsh.com/gushi/chengyu/10696.html http://www.369gsh.com/gushi/chengyu/10695.html http://www.369gsh.com/gushi/chengyu/10694.html http://www.369gsh.com/gushi/chengyu/10703.html
http://www.369gsh.com/gushi/chengyu/10702.html http://www.369gsh.com/gushi/yuyangushi/13665.html http://www.369gsh.com/gushi/yuyangushi/13664.html http://www.369gsh.com/gushi/yuyangushi/13663.html http://www.369gsh.com/gushi/yuyangushi/13662.html http://www.369gsh.com/gushi/yuyangushi/13661.html
http://www.369gsh.com/gushi/yuyangushi/13660.html http://www.369gsh.com/gushi/yuyangushi/13659.html http://www.369gsh.com/gushi/yuyangushi/13658.html http://www.369gsh.com/gushi/yuyangushi/13657.html http://www.369gsh.com/gushi/yuyangushi/13656.html http://www.369gsh.com/gushi/yuyangushi/13566.html
http://www.369gsh.com/gushi/yuyangushi/13565.html http://www.369gsh.com/gushi/yuyangushi/13564.html http://www.369gsh.com/gushi/yuyangushi/13563.html http://www.369gsh.com/gushi/yuyangushi/13562.html http://www.369gsh.com/gushi/yuyangushi/13561.html http://www.369gsh.com/gushi/yuyangushi/13560.html
http://www.369gsh.com/gushi/dongwugushi/13643.html http://www.369gsh.com/gushi/dongwugushi/13642.html http://www.369gsh.com/gushi/dongwugushi/13641.html http://www.369gsh.com/gushi/dongwugushi/13640.html http://www.369gsh.com/gushi/dongwugushi/13639.html http://www.369gsh.com/gushi/dongwugushi/13638.html
http://www.369gsh.com/gushi/dongwugushi/13637.html http://www.369gsh.com/gushi/dongwugushi/13636.html http://www.369gsh.com/gushi/dongwugushi/13635.html http://www.369gsh.com/gushi/dongwugushi/13608.html http://www.369gsh.com/gushi/dongwugushi/13607.html http://www.369gsh.com/gushi/dongwugushi/13606.html
http://www.369gsh.com/gushi/dongwugushi/13605.html http://www.369gsh.com/gushi/dongwugushi/13604.html http://www.369gsh.com/gushi/dongwugushi/13603.html http://www.369gsh.com/gushi/dongwugushi/13602.html http://www.369gsh.com/gushi/dongwugushi/13601.html http://www.369gsh.com/gushi/dongwugushi/13600.html
http://www.369gsh.com/gushi/dongwugushi/13599.html http://www.369gsh.com/gushi/dongwugushi/13598.html http://www.369gsh.com/gushi/dongwugushi/13597.html http://www.369gsh.com/gushi/dongwugushi/13596.html http://www.369gsh.com/gushi/dongwugushi/13595.html http://www.369gsh.com/gushi/dongwugushi/13594.html
http://www.369gsh.com/gushi/dongwugushi/13593.html http://www.369gsh.com/gushi/dongwugushi/13592.html http://www.369gsh.com/gushi/dongwugushi/13591.html http://www.369gsh.com/gushi/dongwugushi/13590.html http://www.369gsh.com/gushi/dongwugushi/13581.html http://www.369gsh.com/gushi/dongwugushi/13476.html
http://www.369gsh.com/gushi/dongwugushi/13475.html http://www.369gsh.com/gushi/dongwugushi/13474.html http://www.369gsh.com/gushi/dongwugushi/13473.html http://www.369gsh.com/gushi/dongwugushi/13472.html http://www.369gsh.com/gushi/dongwugushi/13471.html http://www.369gsh.com/gushi/dongwugushi/13470.html
http://www.369gsh.com/gushi/dongwugushi/13469.html http://www.369gsh.com/gushi/dongwugushi/13468.html http://www.369gsh.com/gushi/dongwugushi/13467.html http://www.369gsh.com/gushi/dongwugushi/13466.html http://www.369gsh.com/gushi/dongwugushi/13465.html http://www.369gsh.com/gushi/dongwugushi/13464.html
http://www.369gsh.com/gushi/dongwugushi/13463.html http://www.369gsh.com/gushi/dongwugushi/13462.html http://www.369gsh.com/gushi/dongwugushi/13461.html http://www.369gsh.com/gushi/dongwugushi/13460.html http://www.369gsh.com/gushi/dongwugushi/13459.html http://www.369gsh.com/gushi/dongwugushi/13458.html
http://www.369gsh.com/gushi/dongwugushi/13457.html http://www.369gsh.com/gushi/dongwugushi/13456.html http://www.369gsh.com/gushi/dongwugushi/13452.html http://www.369gsh.com/gushi/dongwugushi/13451.html http://www.369gsh.com/gushi/dongwugushi/13450.html http://www.369gsh.com/gushi/dongwugushi/13444.html
http://www.369gsh.com/gushi/dongwugushi/13443.html http://www.369gsh.com/gushi/dongwugushi/13442.html http://www.369gsh.com/gushi/dongwugushi/13437.html http://www.369gsh.com/gushi/dongwugushi/13436.html http://www.369gsh.com/gushi/dongwugushi/13435.html http://www.369gsh.com/gushi/dongwugushi/13434.html
http://www.369gsh.com/gushi/dongwugushi/13430.html http://www.369gsh.com/gushi/dongwugushi/13429.html http://www.369gsh.com/gushi/dongwugushi/13425.html http://www.369gsh.com/gushi/dongwugushi/13423.html http://www.369gsh.com/gushi/dongwugushi/13420.html http://www.369gsh.com/gushi/dongwugushi/13419.html
http://www.369gsh.com/gushi/dongwugushi/13417.html http://www.369gsh.com/gushi/dongwugushi/13415.html http://www.369gsh.com/gushi/dongwugushi/13413.html http://www.369gsh.com/gushi/dongwugushi/13412.html http://www.369gsh.com/gushi/dongwugushi/13410.html http://www.369gsh.com/gushi/dongwugushi/13409.html
http://www.369gsh.com/gushi/dongwugushi/13407.html http://www.369gsh.com/gushi/dongwugushi/13406.html http://www.369gsh.com/gushi/dongwugushi/13404.html http://www.369gsh.com/gushi/dongwugushi/13403.html http://www.369gsh.com/gushi/dongwugushi/13386.html http://www.369gsh.com/gushi/dongwugushi/13383.html
http://www.369gsh.com/gushi/dongwugushi/13381.html http://www.369gsh.com/gushi/dongwugushi/13379.html http://www.369gsh.com/gushi/dongwugushi/13376.html http://www.369gsh.com/gushi/dongwugushi/13374.html http://www.369gsh.com/gushi/dongwugushi/13372.html http://www.369gsh.com/gushi/dongwugushi/13370.html
http://www.369gsh.com/gushi/dongwugushi/13368.html http://www.369gsh.com/gushi/dongwugushi/13365.html http://www.369gsh.com/gushi/dongwugushi/13330.html http://www.369gsh.com/gushi/dongwugushi/13328.html http://www.369gsh.com/gushi/dongwugushi/13315.html http://www.369gsh.com/gushi/chengyu/10701.html
http://www.369gsh.com/gushi/chengyu/10421.html http://www.369gsh.com/gushi/chengyu/10420.html http://www.369gsh.com/gushi/chengyu/10419.html http://www.369gsh.com/gushi/chengyu/10418.html http://www.369gsh.com/gushi/chengyu/10417.html http://www.369gsh.com/gushi/chengyu/10416.html
http://www.369gsh.com/gushi/chengyu/10415.html http://www.369gsh.com/gushi/chengyu/10414.html http://www.369gsh.com/gushi/chengyu/10413.html http://www.369gsh.com/gushi/chengyu/10412.html http://www.369gsh.com/gushi/chengyu/9358.html http://www.369gsh.com/gushi/chengyu/10841.html
http://www.369gsh.com/gushi/chengyu/10831.html http://www.369gsh.com/gushi/chengyu/10832.html http://www.369gsh.com/gushi/chengyu/10833.html http://www.369gsh.com/gushi/chengyu/10834.html http://www.369gsh.com/gushi/chengyu/10835.html http://www.369gsh.com/gushi/chengyu/10836.html
http://www.369gsh.com/gushi/chengyu/10837.html http://www.369gsh.com/gushi/chengyu/10838.html http://www.369gsh.com/gushi/chengyu/10839.html http://www.369gsh.com/gushi/chengyu/10840.html http://www.369gsh.com/gushi/chengyu/9664.html http://www.369gsh.com/gushi/chengyu/11106.html
http://www.369gsh.com/gushi/chengyu/10766.html http://www.369gsh.com/gushi/chengyu/8804.html http://www.369gsh.com/gushi/chengyu/11204.html http://www.369gsh.com/gushi/chengyu/10693.html http://www.369gsh.com/gushi/chengyu/10770.html http://www.369gsh.com/gushi/chengyu/10780.html
http://www.369gsh.com/gushi/chengyu/10779.html http://www.369gsh.com/gushi/chengyu/10778.html http://www.369gsh.com/gushi/chengyu/10777.html http://www.369gsh.com/gushi/chengyu/10776.html http://www.369gsh.com/gushi/chengyu/10775.html http://www.369gsh.com/gushi/chengyu/10774.html
http://www.369gsh.com/gushi/chengyu/10773.html http://www.369gsh.com/gushi/chengyu/10772.html http://www.369gsh.com/gushi/chengyu/10771.html http://www.369gsh.com/gushi/chengyu/11099.html http://www.369gsh.com/gushi/chengyu/8832.html http://www.369gsh.com/gushi/chengyu/10830.html
http://www.369gsh.com/gushi/chengyu/10829.html http://www.369gsh.com/gushi/chengyu/10828.html http://www.369gsh.com/gushi/chengyu/10827.html http://www.369gsh.com/gushi/chengyu/10826.html http://www.369gsh.com/gushi/chengyu/10825.html http://www.369gsh.com/gushi/chengyu/10824.html
http://www.369gsh.com/gushi/chengyu/10823.html http://www.369gsh.com/gushi/chengyu/10822.html http://www.369gsh.com/gushi/chengyu/10821.html http://www.369gsh.com/gushi/chengyu/10820.html http://www.369gsh.com/gushi/chengyu/10819.html http://www.369gsh.com/gushi/chengyu/10818.html
http://www.369gsh.com/gushi/chengyu/10817.html http://www.369gsh.com/gushi/chengyu/10816.html http://www.369gsh.com/gushi/chengyu/10815.html http://www.369gsh.com/gushi/chengyu/10814.html http://www.369gsh.com/gushi/chengyu/10813.html http://www.369gsh.com/gushi/chengyu/10812.html
http://www.369gsh.com/gushi/chengyu/10811.html http://www.369gsh.com/gushi/chengyu/10810.html http://www.369gsh.com/gushi/chengyu/10809.html http://www.369gsh.com/gushi/chengyu/10808.html http://www.369gsh.com/gushi/chengyu/10807.html http://www.369gsh.com/gushi/tonghuagushi/13675.html
http://www.369gsh.com/gushi/tonghuagushi/13674.html http://www.369gsh.com/gushi/tonghuagushi/13673.html http://www.369gsh.com/gushi/tonghuagushi/13672.html http://www.369gsh.com/gushi/tonghuagushi/13671.html http://www.369gsh.com/gushi/tonghuagushi/13670.html
http://www.369gsh.com/gushi/tonghuagushi/13669.html http://www.369gsh.com/gushi/tonghuagushi/13668.html http://www.369gsh.com/gushi/tonghuagushi/13667.html http://www.369gsh.com/gushi/tonghuagushi/13666.html http://www.369gsh.com/gushi/tonghuagushi/13554.html
http://www.369gsh.com/gushi/tonghuagushi/13553.html http://www.369gsh.com/gushi/tonghuagushi/13552.html http://www.369gsh.com/gushi/tonghuagushi/13551.html http://www.369gsh.com/gushi/tonghuagushi/13550.html http://www.369gsh.com/gushi/tonghuagushi/13549.html
http://www.369gsh.com/gushi/tonghuagushi/13548.html http://www.369gsh.com/gushi/tonghuagushi/13547.html http://www.369gsh.com/gushi/tonghuagushi/13495.html http://www.369gsh.com/gushi/tonghuagushi/13494.html http://www.369gsh.com/gushi/tonghuagushi/13493.html
http://www.369gsh.com/gushi/tonghuagushi/13492.html http://www.369gsh.com/gushi/tonghuagushi/13491.html http://www.369gsh.com/gushi/tonghuagushi/13490.html http://www.369gsh.com/gushi/tonghuagushi/13489.html http://www.369gsh.com/gushi/tonghuagushi/13488.html
http://www.369gsh.com/gushi/tonghuagushi/13487.html http://www.369gsh.com/gushi/tonghuagushi/11715.html http://www.369gsh.com/gushi/tonghuagushi/11714.html http://www.369gsh.com/gushi/tonghuagushi/11625.html http://www.369gsh.com/gushi/tonghuagushi/9254.html
http://www.369gsh.com/gushi/tonghuagushi/9204.html http://www.369gsh.com/gushi/tonghuagushi/9203.html http://www.369gsh.com/gushi/tonghuagushi/9202.html http://www.369gsh.com/gushi/lishigushi/13682.html http://www.369gsh.com/gushi/lishigushi/13681.html http://www.369gsh.com/gushi/lishigushi/13680.html
http://www.369gsh.com/gushi/lishigushi/13679.html http://www.369gsh.com/gushi/lishigushi/13678.html http://www.369gsh.com/gushi/lishigushi/13677.html http://www.369gsh.com/gushi/lishigushi/13676.html http://www.369gsh.com/gushi/lishigushi/13575.html http://www.369gsh.com/gushi/lishigushi/13574.html
http://www.369gsh.com/gushi/lishigushi/9807.html http://www.369gsh.com/gushi/lishigushi/9806.html http://www.369gsh.com/gushi/lishigushi/9805.html http://www.369gsh.com/gushi/lishigushi/9804.html http://www.369gsh.com/gushi/lishigushi/9803.html http://www.369gsh.com/gushi/lishigushi/9802.html
http://www.369gsh.com/gushi/lishigushi/8753.html http://www.369gsh.com/gushi/minjiangushi/12727.html http://www.369gsh.com/gushi/minjiangushi/9832.html http://www.369gsh.com/gushi/minjiangushi/9831.html http://www.369gsh.com/gushi/minjiangushi/9830.html http://www.369gsh.com/gushi/minjiangushi/9829.html
http://www.369gsh.com/gushi/minjiangushi/9828.html http://www.369gsh.com/gushi/minjiangushi/9827.html http://www.369gsh.com/gushi/minjiangushi/9826.html http://www.369gsh.com/gushi/minjiangushi/9825.html http://www.369gsh.com/gushi/minjiangushi/9824.html http://www.369gsh.com/gushi/minjiangushi/9412.html
http://www.369gsh.com/gushi/minjiangushi/9411.html http://www.369gsh.com/gushi/minjiangushi/9410.html http://www.369gsh.com/gushi/minjiangushi/9409.html http://www.369gsh.com/gushi/minjiangushi/9408.html http://www.369gsh.com/gushi/minjiangushi/9407.html http://www.369gsh.com/gushi/minjiangushi/9403.html
但是一旦多人分工配合作为生存的整体,力量就显得强大多了,所以也自然的形成了族群:有些人种田厉害,有些人制作工具厉害,有些地方适合产出粮食,有些地方适合产出棉花等,就自然形成了人的分群,地域的分群。当分工发生后,实际上每个人的生产力都得到了提高,因为做的都是每个人擅长的事情。
整个人群的生产力和抵抗环境的能力都得到了增强。为什么呢?因为每个人的能力和时间都是有限的,并且因为人的结构的限制,人同时只能专心做好一件事情,这样不得已就导致了分工的产生。既然分工发生了,原来由一个人干生存所必需的所有的事情,就变成了很多不同分工的角色合作完成这些事情,这些人必须要通过某些机制合在一起,让每个人完成生存所必需的事情,这实际上也导致了交易的发生(交易这部分就不在这里展开了,有机会再讨论)。
在每个人都必须自己完成所有生活必须品的生产的时候,是没有架构的(当然在个人来讲,同一时刻只能做有限的事情,在时间上还是可能会产生架构的)。一旦产生的分工,就把所有的事情,切分成由不同角色的人来完成,最后再通过交易,使得每个个体都拥有生活必须品,而不需要每个个体做所有的事情,只需要每个个体做好自己擅长的事情,并具备一定的交易能力即可。
这实际上就形成了社会的架构。那么怎么定义架构呢?以上面这个例子为例,把一个整体(完成人类生存的所有工作)切分成不同的部分(分工),由不同角色来完成这些分工,并通过建立不同部分相互沟通的机制,使得这些部分能够有机的结合为一个整体,并完成这个整体所需要的所有活动,这就是架构。由以上的例子,也可以归纳出架构产生的动力:
必须由人执行的工作(不需要人介入,就意味着不需要改造,也就不需要架构了)
每个人的能力有限(每个人都有自己的强项,个人的产出受限于最短板,并且由于人的结构限制,同时只能专注于做好一件事情,比如虽然有两只眼睛,但是只能同时专注于一件事物,有两只手,无法同时做不同的事情。ps. 虽然有少部分人可以左手画圆右手画框,但是不是普遍现象)
每个人的时间有限(为了减少时间的投入,必然会导致把工作分解出去,给擅长于这些工作的角色来完成,见2,从而缩短时间)
人对目标系统有更高的要求(如果满足于现状,也就不需要进行架构了)
目标系统的复杂性使得单个人完成这个系统,满足条件2,3(如果个人就可以完成系统的提高,也不需要别的人参与,也就不需要架构的涉及,只是工匠,并且一般这个工作对时间的要求也不迫切。当足够熟练之后,也会有一定的架构思考,但考虑更多的是如何提高质量,提高个人的时间效率)
有人可能会挑战说,如果一个人对目标系统进行分解,比如某人建一栋房子,自己采购材料,自己搭建,难道也不算架构嘛?如果对于时间不敏感的话,是会出现这个情况的,但是在这种情况下,并不必然导致架构的发生。如果有足够的自觉,以及足够的熟练的话,也会产生架构的思考,因为这样对于提高生产力是有帮助的,可以缩短建造的时间,并会提高房子的质量。事实上建筑的架构就是在长期进行这些活动后,积累下来的实践。
当这5个条件同时成立,一定会产生架构。从这个层面上来说,架构是人类发展过程中,由懵懵懂懂的,被动的去认识这个世界,变成主动的去认识,并以更高的效率去改造这个世界的方法。以下我们再拿建筑来举例加强一下理解。
最开始人类是住在山洞里,住在树上的,主要是为了躲避其他猛兽的攻击,以及减少自然环境的变化,对人类生存的挑战。为了完成这些目标,人类开始学会在平地上用树木和树叶来建立隔离空间的设施,这就是建筑的开始。但是完全隔离也有很多坏处,慢慢就产生了门窗等设施。
建筑的本质就是从自然环境中,划出一块独占的空间,但是仍然能够通过门窗等和自然环境保持沟通。这个时候架构就已经开始了。对地球上的空间进行切分,并通过门窗,地基等,保持和地球以及空间的有机的沟通。当人类开始学会用火之后,茅棚里面自然而然慢慢就会被切分为两部分,一部分用来烧饭,一部分用来生活。当人的排泄慢慢移入到室内后,洗手间也就慢慢的出现了。这就是建筑内部的空间切分。
这个时候人们对建筑的需求也就慢慢的越来越多,空间的切分也会变成很多种,组合的方式也会有很多种,比如每个人住的房子,群居所产生的宗教性质的房子,集体活动的房子等等。这个时候人们就开始有意识的去设计房子,架构师就慢慢的出现了。一切都是为了满足人的越来越高的需求,提升质量,减少时间,更有效率的切分空间,并且让空间之间更加有机的进行沟通。这就是建筑的架构以及建筑的架构的演变。
总结一下,什么是架构,就是:
根据要解决的问题,对目标系统的边界进行界定。
并对目标系统按某个原则的进行切分。切分的原则,要便于不同的角色,对切分出来的部分,并行或串行开展工作,一般并行才能减少时间。
并对这些切分出来的部分,设立沟通机制。
根据3,使得这些部分之间能够进行有机的联系,合并组装成为一个整体,完成目标系统的所有工作。
同样这个思考可以展开到其他的行业,比如企业的架构,国家的架构,组织架构,音乐架构,色彩架构,软件架构等等。套用三国演义的一句话,合久必分,分久必合。架构实际上就是指人们根据自己对世界的认识,为解决某个问题,主动地、有目的地去识别问题,并进行分解、合并,解决这个问题的实践活动。架构的产出物,自然就是对问题的分析,以及解决问题的方案:包括拆分的原则以及理由,沟通合并的原则以及理由,以及拆分,拆分出来的各个部分和合并所对应的角色和所需要的核心能力等。