译言网 | 你懂编程吗?

来源:百度文库 编辑:神马文学网 时间:2024/04/28 12:12:43

你懂编程吗?

hejiu1989

于2010-08-27 13:34:18翻译 | 已有117人浏览

编程原来有这么多不为人知的道理,.net专家David Veksler告诉你伟大的程序员为什么伟大,烂程序员为何将一如既往的烂下去。

Tags:软件 |   | 编程经验  | 程序员 
My experience as a programmer  has taught me a few things about writing software. Here are some things that people might find surprising about writing code:

多年的程序员经历告诉我一些不为人知的东西: 

A programmer spends about 10-20% of his time writing code, and most programmers write about 10-12 lines of code per day that goes into the final product, regardless of their skill level. Good programmers spend much of the other 90% thinking, researching, and experimenting to find the best design. Bad programmers spend much of that 90% debugging code by randomly making changes and seeing if they work.

程序员编码的时间仅占整个项目的10-20%,不管他们技术多高超,绝大多数程序员每天所写的代码仅有10-12行最终会纳入到最后发布的产品中。优秀的程序员会把令外90%的时间花在思考,探索,去找寻最佳的设计方案。而普通程序员漫无目的的修改他们的代码,不厌其烦的编译调试来看修改是否奏效。

“A great lathe operator commands several times the wage of an average lathe operator, but a great writer of software code is worth 10,000 times the price of an average software writer.” –Bill Gates

“伟大的车工值得付给他几倍于普通车工的薪水,但一个伟大的程序员,其价值则要等同于一个普通程序员的1万倍”。--比尔`盖茨

A good programmer is ten times more productive than an average programmer. A great programmer is 20-100 times more productive than the average. This is not an exaggeration – studies since the 1960′s have consistently shown this. A bad programmer is not just unproductive – he will not only not get any work done, but create a lot of work and headaches for others to fix.

优秀的程序效率十倍于一般程序员,而一个伟大的程序员效率则是普通程序员的20-100倍。这一点都不夸张,上世纪六十年代的研究早就证明了这一断言。烂程序员不仅没法完成分内的工作,还会给后来接手者留下令人抓狂的烂摊子。

Great programmers spend very little of their time writing code – at least code that ends up in the final product. Programmers who spend much of their time writing code are too lazy, too ignorant, or too arrogant to find existing solutions to old problems. Great programmers are masters at recognizing and reusing common patterns. Good programmers are not afraid to refactor (rewrite) their code constantly to reach the ideal design. Bad programmers write code which lacks conceptual integrity, non-redundancy, hierarchy, and patterns, and so is very difficult to refactor. It’s easier to throw away bad code and start over than to change it.

那些把时间都花在写代码的程序员实在太懒,太愚昧,或者根本“不屑于”从自己的经验中寻找现成的解决方案。优秀的程序员擅长总结和重用一些通用的设计模式,为了寻找更加完美的方案,他们会时常重构(or重写)自己的代码。而烂程序员写出来的代码连基本的概念完整性都达不到,更何况没有冗余,拥有明晰的层次结构了,所以这样的代码很难去重构。还不如抛开它自己写一套。

Software obeys the laws of entropy, like everything else. Continuous change leads to software rot, which erodes the conceptual integrity of the original design. Software rot is unavoidable, but programmers who fail to take conceptual integrity into consideration create software that rots so so fast that it becomes worthless before it is even completed. Entropic failure of conceptual integrity is probably the most common reason for software project failure. (The second most common reason is delivering something other than what the customer wanted.) Software rot slows down progress exponentially, so many projects face exploding timelines and budgets before they are killed.

软件和其他万物共同遵循逐渐衰败腐朽的一般原则。无休止的修改只能导致软件最终凌乱不堪,破坏了概念完整性原则,背离原始设计。软件腐朽(定义见wikipedia)虽然无法避免,但是,那些一开始就没有把概念完整性纳入考虑的程序员编写的软件只会更快腐朽以至软件还未完成,代码便不能用了。软件腐朽缺乏完整性所造成的失败是项目失败的罪魁祸首。(其次是忽视客户需求,塞给客户不需要的东西)软件腐朽对软件开发的影响是数以指数级的,很多项目在死掉之前会面临超出期限和预算的巨大挑战。

A 2004 study found that most software projects (51%) will fail in a critical aspect, and 15% will fail totally. This is an improvement since 1994, when 31% failed.

04年的一项研究显示,超过51%的项目在部分模块上面临失败,15%将遭遇完败。相比94年的31%,情况已经大大好转。

Although most software is made by teams, it is not a democratic activity. Usually, just one person is responsible for the design, and the rest of the team fills in the details.

尽管大多数项目都是由团队合作完成,但是很多团队并不是那么民主。大多数团队中只有一个人负责全程设计,剩下的人只是向架构中填充细节而已。

Programming is hard work. It’s an intense mental activity. Good programmers think about their work 24/7. They write their most important code in the shower and in their dreams. Because the most important work is done away from a keyboard, software projects cannot be accelerated by spending more time in the office or adding more people to a project.

编程是个体力活。它同时也在不断磨练你的心智。好的程序员不分昼夜在思考完善自己的项目。他们可能在沐浴甚至是在梦境中构思着至关重要的那部分代码。项目不可能通过程序员呆在办公室花更多的时间或者动用人海战术完成好,因为程序员最最要紧的工作往往是在他们撇开键盘时完成的。1