0%

编程之道 卷五 维护

Book 5 - Maintenance

Thus spake the master programmer:
“Though a program be but three lines long, someday it will have to be maintained.”

编程大师如是说:
“即使是个只有三行代码的程序,也总有一天需要维护。”

5.1

A well-used door needs no oil on its hinges. A swift-flowing stream does not grow stagnant. Neither sound nor thoughts can travel through a vacuum. Software rots if not used.
使用良好的门的铰链不需要上油。快速流动的河不会停滞不前。声音和思想都无法在真空中传播。软件不用也会腐烂。

These are great mysteries.
这些都是非常神奇的事物。

5.2

A manager asked a programmer how long it would take him to finish the program on which he was working.
“It will be finished tomorrow,” the programmer promptly replied.
“I think you are being unrealistic,” said the manager, “Truthfully, how long will it take?”
The programmer thought for a moment. “I have some features that I wish to add. This will take at least two weeks,” he finally said.
“Even that is too much to expect,” insisted the manager, “I will be satisfied if you simply tell me when the program is complete.”
The programmer agreed to this.
Several years later, the manager retired. On the way to his retirement luncheon, he discovered the programmer asleep at his terminal. He had been programming all night.

一位经理向一位程序员询问他当前在做的项目还要做多长时间。
“明天能做完,”程序员马上回答。
“我觉得你估得不靠谱,”经理说,“说真的,多长时间能做完?”
程序员想了一会儿。“我想往里面添加点新功能。这至少得花个两个星期,”他最后这么说。
“即使这样,还是有点夸张,”经理坚决说道:“你只要什么时候做完了再告诉我就行了。”
程序员答应了。
几年过去,经理退休了。在他的退休午餐会上,他发现这位程序员在他的终端前睡着了。他整夜都在编那个程序。

5.3

A novice programmer was once assigned to code a simple financial package.
有个菜鸟程序员被指派去编写一套简单的财务相关的软件包。

The novice worked furiously for many days, but when his master reviewed his program, he discovered that it contained a screen editor, a set of generalized graphics routines, an artificial intelligence interface, but not the slightest mention of anything financial.
这位菜鸟疯狂地工作了数天,当他的主管审查他的代码时,发现他写了一个编辑器,一个图形程序,一个人工智能接口,就是没看到一丁点跟财务相关的东西。

When the master asked about this, the novice became indignant. “Don’t be so impatient,” he said, “I’ll put in the financial stuff eventually.”
当主管问到这一点时,那位菜鸟怒了。“别这么没耐心嘛,”他说,“我会在最后一部分写财务相关的东西。”

5.4

Does a good farmer neglect a crop he has planted?
Does a good teacher overlook even the most humble student?
Does a good father allow a single child to starve?
Does a good programmer refuse to maintain his code?
一个好的农夫会忽视自己地里的庄稼吗?
一个好的老师会忽视自己哪怕是最糟糕的学生吗?
一个好的父亲会让自己的任何一个孩子饿死吗?
一个好的程序员会拒绝去维护自己的代码吗?