[ 软件工程] 56 条原则

# Laws of Software Engineering Ref: Laws of Software Engineering A collection of principles and patterns that shape software systems, teams, and decisions. 一套用于指导软件系统、团队运作及决策制定的原则与模式。 ## Conway's Law 康威定律 Organizations design systems that mirror their own communication structure. 各机构设计的系统都反映了其自身的沟通结构。 ## Premature Optimization (Knuth's Optimization Principle) 过早优化(克努特优化原则) Premature optimization is the root of all evil. 过早优化是一切问题的根源。 ## Hyrum's Law 海勒姆定律 With a sufficient number of API users, all observable behaviors of your system will be depended on by somebody. 只要有足够数量的 API 用户,你系统的所有可观察行为都会被某些人所利用/依赖。 ## The Boy Scout Rule 童子军守则 Leave the code better than you found it. 把代码留得比你接手时更好吧。 ## YAGNI (You Aren't Gonna Need It) YAGNI(你不需要它) Don't add functionality until it is necessary. 除非确实有必要,否则不要添加任何功能。 ## Brooks's Law 布鲁克斯定律 Adding manpower to a late software project makes it later. 在软件项目已经延迟的情况下再增加人力,只会让项目更加延期。 ## Gall's Law 加尔定律 A complex system that works is invariably found to have evolved from a simple system that worked. 一个能够正常运行的复杂系统,必定是从一个能够正常运行的简单系统演变而来的。 ## The Law of Leaky Abstractions 有漏洞的抽象层法则 All non-trivial abstractions, to some degree, are leaky. 所有非平凡的抽象机制,在某种程度上都存在“漏洞”。 ## Tesler's Law (Conservation of Complexity) 泰斯勒定律(复杂性守恒定律) Every application has an inherent amount of irreducible complexity that can only be shifted, not eliminated. 每个系统都存在一定程度的“不可简化复杂性”:这种复杂性只能被调整,而无法被彻底消除。 ## CAP Theorem CAP 定理 A distributed system can guarantee only two of: consistency, availability, and partition tolerance. 分布式系统最多只能同时保证一致性、可用性和分区容错性中的两项。 ## Second-System Effect 第二系统效应 Small, successful systems tend to be followed by overengineered, bloated replacements. 那些小型且成功的系统,往往会被设计过于复杂、结构臃肿的替代品所取代。 ## Fallacies of Distributed Computing 分布式计算的谬误 A set of eight false assumptions that new distributed system designers often make. 新分布式系统设计者常会犯的八种错误假设。 ## Law of Unintended Consequences 意外后果法则 Whenever you change a complex system, expect surprise. 每当你试图改变一个复杂的系统时,都得做好遇到意外情况的准备。 ## Zawinski's Law 扎温斯基定律 Every program attempts to expand until it can read mail. 每个程序都会不断尝试扩展功能,直到能够读取邮件为止。 ## Dunbar's Number 邓巴数 There is a cognitive limit of about 150 stable relationships one person can maintain. 一个人能够维持的稳定人际关系数量大约有一个上限,约为 150 个。 ## The Ringelmann Effect 林格尔曼效应 Individual productivity decreases as group size increases. 随着团队规模的扩大,个人的生产效率会下降。 ## Price's Law 普赖斯定律 The square root of the total number of participants does 50% of the work. 参与总人数的平方根所对应的人数,完成了 50%的工作量。 ## Putt's Law 普特定律 Those who understand technology don't manage it, and those who manage it don't understand it. 那些懂技术的人不会去管理技术,而那些管理技术的人则不懂技术。 ## Peter Principle 彼得原理 In a hierarchy, every employee tends to rise to their level of incompetence. 在等级制度中,每个员工往往都会停留在与其能力水平相称的职位上。 ## Bus Factor 巴士因素 The minimum number of team members whose loss would put the project in serious trouble. 那些一旦离职就会使项目陷入严重困境的团队成员的最少人数。 ## Dilbert Principle 迪尔伯特法则 Companies tend to promote incompetent employees to management to limit the damage they can do. 企业往往会把能力不足的员工提拔到管理岗位,以此来限制他们可能造成的损害。 ## Parkinson's Law 帕金森定律 Work expands to fill the time available for its completion. 工作会自行扩展,以填满完成它所需的时间。 ## The Ninety-Ninety Rule 九九法则 The first 90% of the code accounts for the first 90% of development time; the remaining 10% accounts for the other 90%. 代码中前 90%的部分占据了开发过程中前 90%的时间;剩下的 10%的代码则占据了剩余的 90%的开发时间。 ## Hofstadter's Law 霍夫斯塔特定律 It always takes longer than you expect, even when you take into account Hofstadter's Law. 无论是否考虑到霍夫斯塔特定律,事情发展的时间总是比预期的要长。 ## Goodhart's Law 古德哈特定律 When a measure becomes a target, it ceases to be a good measure. 当一项衡量标准变成了目标本身时,它就不再是一项有效的衡量标准了。 ## Gilb's Law 吉尔布定律 Anything you need to quantify can be measured in some way better than not measuring it. 任何需要被量化的东西,其测量结果总比不测量要好。 ## Murphy's Law / Sod's Law 墨菲定律/糟糕透顶的定律 Anything that can go wrong will go wrong. 凡是可能出错的事情,都一定会出错。 ## Postel's Law 波斯特尔定律 Be conservative in what you do, be liberal in what you accept from others. 做事要保守,接受他人给予的东西则要大方。 ## Broken Windows Theory “破窗理论” Don't leave broken windows (bad designs, wrong decisions, or poor code) unrepaired. 不要让那些有缺陷的“窗户”继续存在下去——无论是由于糟糕的设计、错误的决策,还是低劣的代码所导致的缺陷。 ## Technical Debt 技术债务 Technical Debt is everything that slows us down when developing software. 技术债务,指在软件开发过程中,一切会阻碍我们前进的因素。 ## Linus's Law 林纳斯定律 Given enough eyeballs, all bugs are shallow. 只要人多眼杂,所有的漏洞都显而易见。 ## Kernighan's Law 克尼汉定律 Debugging is twice as hard as writing the code in the first place. 调试的难度是编写代码时的两倍。 ## Testing Pyramid 测试金字塔 A project should have many fast unit tests, fewer integration tests, and only a small number of UI tests. 一个项目应该包含大量的单元测试、较少的集成测试,以及极少量的用户界面测试。 ## Pesticide Paradox 农药悖论 Repeatedly running the same tests becomes less effective over time. 反复进行相同的测试,其效果会随着时间的推移而逐渐降低。 ## Lehman's Laws of Software Evolution 雷曼的软件演化定律 Software that reflects the real world must evolve, and that evolution has predictable limits. 反映现实世界的软件必然会不断发展演变,而这种演变也有一定的限度。 ## Sturgeon's Law 斯特金定律 90% of everything is crap. 90%的东西都是垃圾。 ## Amdahl's Law 阿姆达尔定律 The speedup from parallelization is limited by the fraction of work that cannot be parallelized. 并行化带来的加速效果,受到那些无法被并行处理的工作量的限制。 ## Gustafson's Law 古斯塔夫森定律 It is possible to achieve significant speedup in parallel processing by increasing the problem size. 通过增加问题的规模,可以在并行处理中显著提升处理速度。 ## Metcalfe's Law 梅特卡夫定律 The value of a network is proportional to the square of the number of users. 网络的价值与用户数量的平方成正比。 ## DRY (Don't Repeat Yourself) DRY 原则(不要重复自己) Every piece of knowledge must have a single, unambiguous, authoritative representation. 每一条知识都必须有唯一、明确、权威的表述方式。 ## KISS (Keep It Simple, Stupid) KISS 原则(简单点,别搞复杂了) Designs and systems should be as simple as possible. 设计和系统应尽可能简单。 ## SOLID Principles SOLID 原则 Five main guidelines that enhance software design, making code more maintainable and scalable. 五条提升软件设计质量的核心准则,有助于让代码更易于维护和扩展。 ## Law of Demeter 得墨忒耳法则 An object should only interact with its immediate friends, not strangers. 一个对象应该只与其直接相关的“伙伴”进行交互,而不应与“陌生人”发生交互。 ## Principle of Least Astonishment 最小惊讶原则 Software and interfaces should behave in a way that least surprises users and other developers. 软件和界面的设计应尽可能减少给用户和其他开发者带来的意外。 ## Dunning-Kruger Effect 邓宁-克鲁格效应 The less you know about something, the more confident you tend to be. 你对某件事了解得越少,往往就越自信。 ## Hanlon's Razor 汉隆剃刀原理 Never attribute to malice that which is adequately explained by stupidity or carelessness. 对于那些可以用愚蠢或粗心来解释的事情,千万不要归咎于恶意。 ## Occam's Razor 奥卡姆剃刀原理 The simplest explanation is often the most accurate one. 最简单的解释往往也是最准确的解释。 ## Sunk Cost Fallacy 沉没成本谬误 Sticking with a choice because you've invested time or energy in it, even when walking away helps you. 因为已经在某件事上投入了时间和精力,所以才坚持下去,即使放弃反而会对自己更有利。 ## The Map Is Not the Territory 地图并非现实领土的写照 Our representations of reality are not the same as reality itself. 我们对现实的描述与现实本身并不相同。 ## Confirmation Bias 确认偏误 A tendency to favor information that supports our existing beliefs or ideas. 倾向于选择那些能支持我们现有信念或观点的信息。 ## The Hype Cycle & Amara's Law 炒作周期与阿玛拉定律 We tend to overestimate the effect of a technology in the short run and underestimate the impact in the long run. 我们往往高估了某种技术在短期内的效果,而低估了其长期影响。 ## The Lindy Effect 林迪效应 The longer something has been in use, the more likely it is to continue being used. 某样东西被使用的时间越长,它被继续使用的可能性就越大。 ## First Principles Thinking 第一性原理思维 Breaking a complex problem into its most basic blocks and then building up from there. 将复杂问题拆解为最基本的组成部分,然后再逐步构建起来。 ## Inversion 反转/倒置 Solving a problem by considering the opposite outcome and working backward from it. 通过考虑相反的结果,然后从反方向着手来解决问题。 ## Pareto Principle (80/20 Rule) 帕累托原则(80/20 法则) 80% of the problems result from 20% of the causes. 80%的问题源于 20%的原因。 ## Cunningham's Law 坎宁安定律 The best way to get the correct answer on the Internet is not to ask a question, it's to post the wrong answer. 在互联网上得到正确答案的最好方法,不是去提问,而是发布错误的答案。

Date:
Words:
2759
Time to read:
13 mins