Ten Commandments of Programming
December 31, 2020 • ☕️ 3 min read
“谦逊编程”十条诫律:
理解和接受你将犯下的“错误”。
重点是及早的发现你已经犯下的错误,当代码投入使用以后,改动起来就会非常的困难。你的代码不能代表你的人。
记住始终要 Review 你的代码,即便你已经认为无懈可击,经验证明总能发现些错误。不管怎么样,有些“奇技淫巧”总能派上用场,而可能这些技巧别人知道的比你更多。
如果你坚持不耻下问,你的同伴总能分享你更多。不要在完全没有沟通的情况下,自作多情的进行代码重构。
当你确定要更改别人的代码时,必须加上良好的修改记录,这也是出于对他人的种尊重。对待那些新手要保持充分的尊重、细心以及耐心。
记住当他们成长起来后,能帮你解决的问题会比你想象中的还要多。唯一不变的是变化。
怀着开放的心态对待变化,对于各种需求、平台甚至开发工具的变更,应该是迅速适应而不是牢骚满腹 — 这样解决不了问题。真正的权威来自学识,而不是立场。
权威源自学识、尊重源自权威。优雅的接受失败。
最终你的一些观点将会被推翻,即便你有能力证明你的观点是正确的,请不要重复的争辩。帮助其他人意识到这点的最好工具,就是你的理解以及时间。不要成为“办公室男”。
不要在昏暗的办公室里独自喝着可乐敲着代码。当与外界隔绝,离开同伴的视线,也就说明你离开了一个开放、合作的环境。批判代码而不是编写它的人。
要知道你的意见可以影响到代码也可以影响到其人,如果你想尝试下如何打击别人的自信并造成冲突,那么尝试下吧。
Ten Commandments of 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, so 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.
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.
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.
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 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.
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.`
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.