The Codeless Code: Case 18 Necessary Features
This same monk of the Elephant’s Footprint was poring over the code created by his clan. There were several competing implementations of a particular Data Access Object; at present he was attempting to decide which would become the definitive one that his clan would adopt.
象印城的一个僧侣正在琢磨这个城写出来的代码。一个特定的书存储对象通常要经过好几种备选的方案反复比较之后来决定,现在,这个僧侣正尝试着去判断那种方案会被城中的主流所选中。
“Each implementation has its own particular virtues and vexations,” said the monk to the Java master. “And each has features the others lack. I must consign all but one to the winds of oblivion. How am I to choose?”
“每一种实施方案都有其独特的优势和缺陷”,这个僧侣向Java大师说道,“而且,每一个都有其他所没有的长处,我必须要在这么多中只选择一个出来,我该如何进行抉择呢?”
“I cannot answer when I am thirsty,” said the master. “In the cabinet beside you are three wooden cups. Fill one from the river, the second from the temple well, and the third from the water-seller in the village. Bring all back to me without a drop spilled, and I will offer you what help I can.”
“我无法告诉你我什么时候是最口渴的”,大师回答到,“打开旁边的橱柜,你可以发现有三个木杯,第一个木杯中装满了溪水,第二个木杯装满了寺中的井水,第三个杯子装满了从周围村买来的水,你把这三个杯子都给我端过来,中间不能撒漏一滴,我就告诉你该怎么对你说的那种情况作取舍。”
The monk did this, and set all three vessels before the master.
僧侣就照着大师的吩咐去做了,把三杯水都端到大师的面前。
“What have you learned?” asked the master.
“你明白了吗?”,大师问他。
The monk bowed. “If you give a coin to the water-seller in the village, he will strike a gong twice: once before filling your cup, and again when you have had your first sip. If you fill your cup from the temple well, no gong sounds but the bucket is heavy. If you dip your cup in the river, the fish are troubled and the river-god must be appeased by a gift of ten white stones.”
僧侣鞠躬,答到:“如果你向卖给你水的村民支付金币,他们会再给你来送水:当你喝下第一口的时候,你的杯子就会再被倒满水;如果你用寺里的井水去装满杯子,那是不会有任何声音的,但是每天从井里打水的水桶,就会变的比往日沉重;如果你用溪水去装满杯子,溪中的鱼儿就倒了霉了,河神必须向水中投入10颗白石作为礼物去安抚它们。”
“I can drink but one of these,” said the master. “Which will I find the most pleasing?”
“我只能喝其中的一杯”,大师说,“那我应该去喝那一杯最好呢?。”
The monk considered carefully. “The river was cold, but not altogether clear. The temple well I have drunk from in the past: its waters are bitter with limestone. And though I am not acquainted with the water-seller, I heard his gong many times today. On this evidence, I would choose the cup from the water-seller.”
僧侣沉思良久,答:“河水非常凉爽,但并不干净;井水我以前也喝过,味道有些苦涩且杂质不少;尽管我并不了解卖水的人怎么样,但我今天听到很多次他卖水的叫卖声,根据这个推断,我会选择从卖的水来装满您杯子。”
“A most sensible conclusion,” said the master. “Indeed, I have visited this same water-seller every morning for eight years, and found the experience perfectly satisfying each time. Which is the vessel that he filled?”
“一个非常明智的结论”,大师说道,“确实,八年来,我每天早晨都喝卖水的这些人有来往,觉得每次都非常满意。他们运来的水,你说的那个水,装满的是那个杯子?你尝尝”
The master sipped from the indicated cup, and his face fell in disappointment. “Young brother,” he said. “You have completely misunderstood my thirst. Where is the sound of the gong?”
僧侣喝了一口他指的那个杯子中的水,水太难喝了,以至于让这个僧侣失望的底下了头,“年轻人”,大师说,“你完全误解我的意思了,你说的声音在那啊?”(读者注:在设计一个项目方案中,固然有非常多的设计备选方案可供选择,但不要被各种眼花缭乱的方案的优点所迷惑,真正有参考价值的优点,只在符合当下的项目方案的必要特特点上,其他的非必要的特征,再好,也不重要;文中大师让僧侣去选一杯最可口的水,僧侣不是以口感为筛选标准,而且以卖水人的叫卖声为参考依据,这样如何能选出一杯口感上品的水呢?)
The master’s thirst is unsatisfied yet the monk has his answer—what sound was the vessel that poured it?
The monk would have fared better if he had set a brass censer on the window-ledge and merely waited for rain.
The Codeless Code: Case 19 By any other name
The old scribe was asked why, in his official accounts, the temples and the clans were named but the many monks and priests were not.
一个老书吏被问责到:为什么在他维护的以修道院和部落名称命名的官方账户中,许多僧侣和祭司的名称都找不到?
“If I gave you a sheet of figures to tally, would you first bestow a name upon each number seven?” asked the scribe, dismissing the questioner with a wave of an ink-stained hand.
“如果我给你一个计数用的工作表格,你会为表格中的每个数字7起名字吗?”,老书吏反问道,同时,他将沾满墨水的手摆了摆,示意众人散去。
This was mentioned to the Java master, who nodded and finished his tea.
此事被上报到了Java大师那里,大师点了点头喝完了茶。
The next morning the scribe ascended to his office, only to find the following written in thick block letters above the door:
等到第二天早晨,老书吏一到他的办公室,发现在他的门上用厚厚的笔体写着如下的一行字:
public static final int NUM_DAYS_IN_WEEK =
At this, the old scribe Qi was enlightened.
这时,老书吏如醍醐灌顶一般,一下子全明白了!(老书吏之前口口声声说,没有更好的命名方式,但到了Java大师告诉他,用Java来命名的话,就可以将他之前命名方式所带来的所以弊端,都给解决掉了,所以,他非常的惊讶,也一下子全明白了!)