简化根本复杂性,消除偶发复杂性
Neal Ford
尼尔·福特
ESSENTIAL COMPLEXITY REPRESENTS the difficulty inherent in any problem. For example, coordinating a nation's air traffic is an inherently complex problem. Every plane's exact position (including altitude), speed, direction, and destination must be tracked in real time to prevent mid-air and runway collisions. The flight schedules of aircraft must be managed to avoid airport congestion in a continuously changing environment—a severe change in weather throws the entire schedule out of whack.
根本复杂性(Essential complexity)指的是问题与生俱来的难度,它是不可避免的。比如说,协调全国的空中交通有其内在的复杂性,必须实时跟踪每架飞机的位置(包括飞行高度)、速度、航向和目的地,才能预防空中和跑道上的冲突。像天气骤变这样的情况会令航班计划全盘失效,所以航班时刻表唯有适应瞬息万变的环境才能避免机场拥塞。
Conversely, accidental complexity grows from the things we feel we must build to mitigate essential complexity. The antiquated air traffic control system used today is an example of accidental complexity. It was designed to address the essential complexity of controlling the traffic of thousands of airplanes, but the solution itself introduces its own complexity. In fact, the air traffic control system used today is so complex that updating it has proven difficult, if not impossible. In much of the world, air traffic is guided by technology that is more than 30 years old.
与之相反,偶发复杂性(accidental complexity)是从人们解决根本复杂性的过程中衍生出来的。目前陈旧的空中交管系统,就是一个偶发复杂性的例子。系统设计的初衷是为了管理数以千计的飞机参与的交通活动,即解决根本复杂性,但是解决方案本身带来了新的问题。当前的空中交管系统之复杂臃肿难以改善,已是不争的事实,全球多数地区的空中交管系统仍然在使用三十多年前的技术。
Many frameworks and vendor "solutions" are the symptoms of the accidental complexity disease. Frameworks that solve specific problems are useful. Over-engineered frameworks add more complexity than they relieve.
许多软件框架,以及厂商提供的“解决方案”都表现出偶发复杂性的症状。针对特定问题设计的框架才有价值,过度设计的框架往往适得其反——增加的麻烦远远超过缓解的复杂性。
Developers are drawn to complexity like moths to a flame—frequently with the same result. Puzzle solving is fun, and developers are problem solvers. Who doesn't like the rush of solving some incredibly complex problem? In large-scale software, though, removing accidental complexity while retaining the solution to the essential complexity is challenging.
开发人员对复杂问题的痴迷常常导致相同的后果——飞蛾扑火。谁能拒绝迅速解决复杂问题带来的快感?但是开发者应该解决问题,而不是解迷取乐。在大型软件项目中,关注根本复杂性,消除偶发复杂性,抽丝剥茧制订解决方案,才是目前真正的挑战。
How do you do this? Prefer frameworks derived from working code rather than ones cast down from ivory towers. Look at the percentage of code you have in a solution that directly addresses the business problem versus code that merely services the boundary between the application and the users. Cast a wary eye on vendor-driven solutions. They may not be inherently bad, but vendors often push accidental complexity. Make sure that the solution fits the problem.
该怎么做呢?尽量选择来自实际项目的框架,警惕那些理论化的东西;分析方案中有多少代码直接用来解决业务问题,有多少只是用来实现用户与应用之间的交互;谨慎使用厂商驱动的方案,它们并非一无是处,但往往包含偶发复杂性;量体裁衣,确保为问题制订“合身”的解决方案。
It's the duty of the architect to solve the problems inherent in essential complexity without introducing accidental complexity.
架构师的责任在于解决问题的根本复杂性,同时避免引入偶发复杂性。
作者介绍
Neal Ford is a software architect and meme wrangler at ThoughtWorks, a global IT consultancy with an exclusive focus on end-to-end software development and delivery. He is the designer/developer of applications, instructional materials, magazine articles, courseware, and video/DVD presentations, and he is author and/or editor of five books. He also speaks at lots of conferences. You can assuage your ravenous curiosity about Neal at http://www.nealford.com.
尼尔·福特是 ThoughtWorks 公司的软件架构师和文化基因辩论者( Meme Wrangler ) 。 ThoughtWorks 是一家全球性的 IT 咨询公司 , 专注于端到端的软件开发与交付。尼尔设计、开发软件,编写教材,撰写杂志文章,制作课件,录制视频( DVD )演讲,出版过 5 本书,参加众多会议并发言。你可以通过他的个人网站( http://www.nealford.com )更多地了解他。