Part1. INTRODUCTION 概述
It doesn’t take a huge amount of knowledge and skill to get a program working. Kids in high school do it all the time. Young men and women in college start billion-dollar businesses based on scrabbling together a few lines of PHP or Ruby. Hoards of junior programmers in cube farms around the world slog through massive requirements documents held in huge issue tracking systems to get their systems to “work” by the sheer brute force of will. The code they produce may not be pretty; but it works. It works because getting something to work—once—just isn’t that hard.
编写并调试一段代码直到成功运行并不需要特别高深的知识和技能,现在的一名普通高中生都可以做到。有的大学生甚至通过拼凑一些 PHP 或 Ruby 代码就可以 创办一个市值 10 亿美元的公司。想象一下,世界上有成群的初级程序员挤在大公司的隔板间里,日复一日地用蛮力将记录在大型问题跟踪系统里的巨型需求文档一点点转化为能实际运行的代码。他们写出的代码可能不够优美,但是确实能够正常工作。因为创造一个能正常运行的系统——哪怕只成功运行一次——还真不是一件特别困难的事。
Getting it right is another matter entirely. Getting software right is hard. It takes knowledge and skills that most young programmers haven’t yet acquired. It requires thought and insight that most programmers don’t take the time to develop. It requires a level of discipline and dedication that most programmers never dreamed they’d need. Mostly, it takes a passion for the craft and the desire to be a professional.
但是将软件架构设计做好就完全另当别论了。软件架构设计是一件非常困难的情,这通常需要大多数程序员所不具备的经验和技能。同时,也不是所有人都愿意花时间来学习和钻研这个方向。做一个好的软件架构师所需要的自律和专注程度可能会让大部分程序员始料未及,更别提软件架构师这个职业本身的社会认同感与人们投身其中的热情了。
And when you get software right, something magical happens: You don’t need hordes of programmers to keep it working. You don’t need massive requirements documents and huge issue tracking systems. You don’t need global cube farms and 24/7 programming.
但是,一旦将软件架构做好了,你就会立即体会到其中的奥妙:维持系统正常运转再也不需要成群的程序员了;每个变更的实施也不再需要巨大的需求文档和复杂的任务追踪系统了;程序员们再也不用缩在全球各地的隔板间里,24 x 7(即每天 24 小时,每星期 7 天)地疯狂加班了。
When software is done right, it requires a fraction of the human resources to create and maintain. Changes are simple and rapid. Defects are few and far between. Effort is minimized, and functionality and flexibility are maximized.
采用好的软件架构可以大大节省软件项目构建与维护的人力成本。让每次变更都短小简单,易于实施,并且避免缺陷,用最小的成本,最大程度地满足功能性和灵活性的要求。
Yes, this vision sounds a bit utopian. But I’ve been there; I’ve seen it happen. I’ve worked in projects where the design and architecture of the system made it easy to write and easy to maintain. I’ve experienced projects that required a fraction of the anticipated human resources. I’ve worked on systems that had extremely low defect rates. I’ve seen the extraordinary effect that good software architecture can have on a system, a project, and a team. I’ve been to the promised land.
是的,这可能有点像童话故事一样不可信,但是这些又确实是我的亲身经历。我曾经见过因为采用了好的软件架构设计,使得整个系统构建更简单、维护更容易的情况。我也见过因为采用了好的软件架构设计,整个项目最终比预计所使用的人力资源更少,而且更快地完成了。我真真切切地体会过,好的软件架构设计为整个系统所带来的翻天覆地的变化,绝不忽悠。
But don’t take my word for it. Look at your own experience. Have you experienced the opposite? Have you worked on systems that are so interconnected and intricately coupled that every change, regardless of how trivial, takes weeks and involves huge risks? Have you experienced the impedance of bad code and rotten design? Has the design of the systems you’ve worked on had a huge negative effect on the morale of the team, the trust of the customers, and the patience of the managers? Have you seen teams, departments, and even companies that have been brought down by the rotten structure of their software? Have you been to programming hell?
请读者回头想想自己的亲身经历,你肯定经历过这样的情境:某个系统因为其组件错综复杂,相互耦合紧密,而导致不管多么小的改动都需要数周的恶战才能完成。又或是某个系统中到处充满了腐朽的设计和连篇累牍的恶心代码,处处都是障碍。再或者,你有没有见过哪个系统的设计如此之差,让整个团队的士气低落,客户天天痛苦,项目经理们手足无措?你有没有见过某个软件系统因其架构腐朽不堪.而导致团队流失,部门解散,甚至公司倒闭?作为一名程序员,你在编程时体会过那种生不如死的感觉吗?
I have—and to some extent, most of the rest of us have, too. It is far more common to fight your way through terrible software designs than it is to enjoy the pleasure of working with a good one.
以上这些我也都切身体会过。我相信绝大部分读者也或多或少会有共鸣。好的软件架构太难得了,我们职业生涯的大部分时间可能都在和差的架构做斗争,而没有机会一睹优美的架构究竟是什么样子。