Design

字號(hào):

Thus spake the master programmer:
    編程大師如是說(shuō):
    "When program is being tested, it is too late to make design changes."
    程序被測(cè)試時(shí)再去改變它的設(shè)計(jì)已經(jīng)太晚了?!?BR>    3.1 There once was a man who went to a computer trade show. Each day as he entered, the man told the guard at the door:
    曾經(jīng)有一個(gè)人參加計(jì)算機(jī)展覽,每天他進(jìn)門(mén)時(shí)都對(duì)門(mén)衛(wèi)說(shuō):
    "I am a great thief, renowned for my feats of shoplifting. Be forewarned, for this trade show shall not escape unplundered."
    “先警告你,我是偷盜高手,我入室偷盜的本領(lǐng)聞名遐邇。這次展覽會(huì)也再劫難逃?!?BR>    This speech disturbed the guard greatly, because there were millions of dollars of computer equipment inside, so he watched the man carefully. But the man merely wandered from booth to booth, humming quietly to himself.
    警衛(wèi)因此大動(dòng)干戈,因?yàn)槔锩嬗袃r(jià)值百萬(wàn)的計(jì)算機(jī)設(shè)備,所以他牢牢盯緊了這個(gè)人,但是這個(gè)人只是從一個(gè)攤位逛到另一個(gè)攤位,一邊平靜地喃喃自語(yǔ)。
    When the man left, the guard took him aside and searched his clothes, but nothing was to be found.
    當(dāng)這個(gè)人離開(kāi)時(shí),警衛(wèi)搜了他的身,但是什么也沒(méi)有發(fā)現(xiàn)。
    On the next day of the trade show, the man returned and chided the guard saying: "I escaped with a vast booty yesterday, but today will be even better." So the guard watched him ever more closely, but to no avail.
    展覽會(huì)的第二天,這個(gè)人又對(duì)警衛(wèi)說(shuō):“昨天我滿載而歸,但是今天我會(huì)收獲更大?!彼跃l(wèi)更加小心地盯緊他,但是這樣做完全于事無(wú)補(bǔ)。
    On the final day of the trade show, the guard could restrain his curiosity no longer. "Sir Thief," he said, "I am so perplexed, I cannot live in peace. Please enlighten me. What is it that you are stealing?"
    展覽會(huì)的最后一天,警衛(wèi)再也不能忍住他的好奇心了。“小偷先生,”他說(shuō),“ 你說(shuō)我驚慌不安,請(qǐng)告訴我,你到底偷了什么?”。
    The man smiled. "I am stealing ideas," he said.
    這個(gè)人笑笑說(shuō):“我在偷想法?!?BR>    3.2 There once was a master programmer who wrote unstructured programs. A novice programmer, seeking to imitate him, also began to write unstructured programs. When the novice asked the master to evaluate his progress, the master criticized him for writing unstructured programs, saying: "What is appropriate for the master is not appropriate for the novice. You must understand the Tao before transcending structure."
    有一位編程大師,他寫(xiě)非結(jié)構(gòu)化的程序,一位初學(xué)者刻意模仿他,也寫(xiě)非結(jié)構(gòu)化的程序。當(dāng)他讓大師看他的進(jìn)步時(shí),大師批評(píng)了他的非結(jié)構(gòu)化程序:“ 對(duì)一位編程大師合適的東西未必對(duì)一個(gè)初學(xué)者同樣合適,在超越結(jié)構(gòu)化之前,你必須理解編程之道。”
    3.3 There was once a programmer who was attached to the court of the warlord of Wu. The warlord asked the programmer: "Which is easier to design: an accounting package or an operating system?"
    有人問(wèn)一位程序員,“一個(gè)財(cái)務(wù)軟件和一個(gè)操作系統(tǒng)哪個(gè)更容易設(shè)計(jì)?”
    "An operating system," replied the programmer.
    “是操作系統(tǒng)”,這位程序員回答說(shuō)。
    The warlord uttered an exclamation of disbelief. "Surely an accounting package is trivial next to the complexity of an operating system," he said.
    此人大惑不解。他說(shuō):“顯然一個(gè)財(cái)務(wù)軟件比起操作系統(tǒng)來(lái)說(shuō)其復(fù)雜性是微不足道的”。
    "Not so," said the programmer, "when designing an accounting package, the programmer operates as a mediator between people having different ideas: how it must operate, how its reports must appear, and how it must conform to the tax laws. By contrast, an operating system is not limited my outside appearances. When designing an operating system, the programmer seeks the simplest harmony between machine and ideas. This is why an operating system is easier to design."
    程序員說(shuō):“不,設(shè)計(jì)財(cái)務(wù)軟件時(shí),一個(gè)程序員必須成為持不同意見(jiàn)的用戶與計(jì)算機(jī)的一個(gè)中介,他必須了解用戶的操作習(xí)慣,報(bào)表要是什么形式,如何遵循稅法。相反,一個(gè)操作系統(tǒng)完全與這些外部的東西無(wú)關(guān)。設(shè)計(jì)操作系統(tǒng),程序員只需要達(dá)到自己的設(shè)想與機(jī)器之間的簡(jiǎn)單的和諧。這就是為什么操作系統(tǒng)反而比財(cái)務(wù)軟件更容易設(shè)計(jì)?!?BR>    The warlord of Wu nodded and smiled. "That is all good and well, but which is easier to debug?"
    這些人笑著說(shuō)?!安诲e(cuò),但是哪一個(gè)更容易調(diào)試呢?”
    The programmer made no reply.
    程序員沒(méi)有回答。
    3.4 A manager went to the master programmer and showed him the requirements document for a new application. The manager asked the master: "How long will it take to design this system if I assign five programmers to it?"
    一個(gè)項(xiàng)目經(jīng)理帶給編程大師一個(gè)項(xiàng)目的需求,然后問(wèn)大師:“如果我給你5個(gè)程序員,要多少時(shí)間設(shè)計(jì)這個(gè)項(xiàng)目?”
    "It will take one year," said the master promptly.
    “一年”,大師說(shuō)。
    "But we need this system immediately or even sooner! How long will it take it I assign ten programmers to it?"
    “但是我們等不了那么長(zhǎng)時(shí)間,越快越好,如果10程序員呢?”
    The master programmer frowned. "In that case, it will take two years."
    大師皺了一下眉頭說(shuō):“那就要花2年”。
    "And what if I assign a hundred programmers to it?"
    “那,100年程序員呢?”
    The master programmer shrugged. "Then the design will never be completed," he said.
    大師聳了聳肩說(shuō):“那這個(gè)項(xiàng)目就永遠(yuǎn)完不成了?!?BR>