编程十诫
-
理解并接受你也会犯错误。关键在于:在携带盲点投入生产之前要先找到它们。幸运的是,在我们的作业中,除了在实验室开发火箭制导软件,错误并不是招招致命的。我们可以,而且应该学习、放松,并继续学习。
-
你不是你的代码。面对公开(公众性)的事物,不要太过个人化(极端)。反思自己,温故而知新。
-
山外有山,人外有人。虚心求教,尤其是当你觉得没必要的时候。三人行,必有我师。
-
不要在未经咨询参考的情况下重写代码。要知道「修复代码」和「重写代码」之间的区别,在框架内追求风格的改善。独立思考不是独自思考。
-
尊重每一个人,保持耐心、求同存异。那些不经常与开发者来往的非技术人员通常认为我们是自傲且脆弱的。不要用你的愤怒和急躁去加深这些刻板印象。
-
唯一不变的就是改变。开放包容、乐于接受。当你的需求、平台或者开发工具发生改变时,把它当作一次挑战,逃离舒适区。
-
道理(权威)来自于知识(事实),而不是立场(职位)。知识造就道理,道理成就尊重。所以如果你想在一个公正的环境中获得尊重 —— 学,习。
-
争你所信。同时,优雅地面对失败。要知道你的观点肯定会被驳回,即使你是对的,也不要咄咄逼人。
-
不要做一个「在角落里的程序员」。不要只有在拿苏打水的时候才从黑暗的办公室里出来一次。角落里的程序员是脱节的、淡出视线且失控的。这类人在开放协作的环境中从不出声。在沟通中解决问题,融入办公社区。
-
批判程序,而不是批判程序员。尽可能的使用正面积极的评论,一切以改进代码为本。
From The Psychology of Computer Programming , written in 1971, here are The Ten Commandments of Egoless Programming:
-
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. We can, and should, learn, laugh, and move on.
-
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.
-
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, especially when you think it’s not needed.
-
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.
-
Treat people who know less than you with respect, deference, and patience. Non-technical 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.
-
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, rather than some serious inconvenience to be fought.
-
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.
-
Fight for what you believe, but gracefully accept defeat. Understand that sometimes your ideas will be overruled. Even if you are right, don’t take revenge or say “I told you so.” Never make your dearly departed idea a martyr or rallying cry.
-
Don’t be “the coder in the corner.” Don’t be the person in the dark office emerging only for soda. The coder in the corner is out of sight, out of touch, and out of control. This person has no voice in an open, collaborative environment. Get involved in conversations, and be a participant in your office community.
-
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.