无我编程的十大戒律最早出现在 1971 年 Gerald Weinberg 出版的《 程序开发心理学 》里。后由 Stack Overflow 网站的联合创始人 Jeff Atwood 在博客中整理列出。虽然过去了几十年,但这些经典原则仍值得每一位程序员拜读。(编译:开源中国)
1、理解并接受自己会犯错的事实- 犯错无法避免,关键要在错误进入生成环境前及时找出。幸好除了一小部分需要在 JPL(喷气推进实验室)开发火箭指导软件的程序员外,大部分程序员都不会因错误招致生命危险。所以我们要从错误中学习,改过并继续前行。
2、公正地处理代码- 要记住,代码审查是为了找出问题,并且最终一定会发现问题所在。不要因为代码中的某一错误而对人产生偏见。
3、山外有山,人外有人- 不管你怀揣了多少“秘笈”,都不要低估了别人的水平。只要你愿意开口请教,一定会有人教你你所不知道的东西。当你认为某件事没有必要做的时候,不凡问问他人的建议。
4、不在没有协商的情况下重写代码- “修复代码”和“重写代码”有明显的区别。要了解它们之间的差异,并在代码审查的框架内进行程式化的变更,而不是孤军奋战。
5、尊重求教者,并耐心待之- 与技术人员打过交道的非技术人员通常会认为:这些专业人士虽技术知识过硬,但妄自尊大。因此,我们要用耐心和谦和来消除他们对技术人员的误解。
6、世界唯一的不变就是改变- 对世界敞开胸怀,微笑着拥抱变化。把每次需求、平台或者工具的变化看做是一次挑战,而不是一堆麻烦。
7、真正的权威来源于才能,而非职位- 知识造就权威,权威带来尊重。所以,如果你想在一个无我的环境中得到尊重,先积累知识吧。
8、坚定自己的立场,优雅地面对挫折- 你的想法有时候会被推翻。即使你能证明它是对的,也不用试图报复反对它的人,不要大声嚷嚷:“我早就说过......”。不要把被推翻的想法看做是牺牲品,也不要把它当初战败的哀嚎。
9、不要封闭自己- 不要成为一个在小黑屋写代码的人,只在买可乐的时候才出来一下。这样你会失去与外界的联系,淡出人们的视线,失去控制。在开放的协作环境里,你会失去自己的位置。
10、对“码”不对人- 批评代码,而不是编码的人。尽可能的让你的言论积极向上,带动代码质量的提升。多多谈及局部标准、程序规范和更好的性能等。
一一一一一一一萌萌哒分割线一一一一一一一
下面附上作者的原文:
The Ten Commandments of Egoless Programming, as originally established in Jerry Weinberg's book The Psychology of Computer Programming:
1、Understand and accept that you will make mistakes.The point is to find them early, before they make it into production. Fortunately, except for the few of us developing rocket guidance software at JPL, mistakes are rarely fatal in our industry, so we can, and should, learn, laugh, and move on.
2、You are not your code.Remember that the entire point of a review is to find problems, and problems will be found. Don't take it personally when one is uncovered.
3、No matter how much "karate" you know, someone else will always know more.Such an individual can teach you some new moves if you ask. Seek and accept input from others,especiallywhen you think it's not needed.
4、Don't rewrite code without consultation.There's a fine line between "fixing code" and "rewriting code." Know the difference, and pursue stylistic changes within the framework of a code review, not as a lone enforcer.
5、Treat people who know less than you with respect, deference, and patience.Nontechnical people who deal with developers on a regular basis almost universally hold the opinion that we are prima donnas at best and crybabies at worst. Don't reinforce this stereotype with anger and impatience.
6、The only constant in the world is change.Be open to it and accept it with a smile. Look at each change to your requirements, platform, or tool as a new challenge, not as some serious inconvenience to be fought.
7、The only true authority stems from knowledge, not from position.Knowledge engenders authority, and authority engenders respect – so if you want respect in an egoless environment, cultivate knowledge.
8、Fight for what you believe, but gracefully accept defeat.Understand that sometimes your ideas will be overruled. Even if you do turn out to be right, don't take revenge or say, "I told you so" more than a few times at most, and don't make your dearly departed idea a martyr or rallying cry.
9、Don't be "the guy in the room."Don't be the guy coding in the dark office emerging only to buy cola. The guy in the room is out of touch, out of sight, and out of control and has no place in an open, collaborative environment.
10、Critique code instead of people – be kind to the coder, not to the code.As much as possible, make all of your comments positive and oriented to improving the code. Relate comments to local standards, program specs, increased performance, etc.
The human principles of software are truly timeless;The Psychology of Computer Programmingwas written way back in 1971, a year after I was born!