📄 00000003.htm
字号:
<HTML><HEAD> <TITLE>BBS水木清华站∶精华区</TITLE></HEAD><BODY><CENTER><H1>BBS水木清华站∶精华区</H1></CENTER>发信人: ClearMind (我是谁?), 信区: Linux <BR>标 题: [连载]编程之道:Part II(英文) <BR>发信站: BBS 水木清华站 (Mon Oct 23 11:52:58 2000) <BR> <BR><The Tao of Programming> Part II: <BR>======Beginning of Part II======= <BR> <BR> Coding <BR> Book Four <BR> _____________________________________________________ <BR> <BR> Thus spake the master programmer: <BR> <BR> "A well-written program is its own heaven; <BR> a poorly-written program is its own hell." <BR> _____________________________________________________ <BR> <BR> 4.1 <BR> A program should be light and agile, its subroutines connected <BR> like a strings of pearls. The spirit and intent of the program <BR> should be retained throughout. There should be neither too <BR> little nor too much, neither needless loops nor useless <BR> variables, neither lack of structure nor overwhelming rigidity. <BR> <BR> A program should follow the 'Law of Least Astonishment'. What <BR> is this law? It is simply that the program should always <BR> respond to the user in the way that astonishes him least. <BR> <BR> A program, no matter how complex, should act as a single unit. <BR> The program should be directed by the logic within rather than <BR> by outward appearances. <BR> <BR> If the program fails in these requirements, it will be in a <BR> state of disorder and confusion. The only way to correct this <BR> is to rewrite the program. <BR> <BR> 4.2 <BR> A novice asked the master: "I have a program that sometimes <BR> runs and sometimes aborts. I have followed the rules of <BR> programming, yet I am totally baffled. What is the reason for <BR> this?" <BR> <BR> The master replied: "You are confused because you do not <BR> understand the Tao. Only a fool expects rational behavior from <BR> his fellow humans. Why do you expect it from a machine that <BR> humans have constructed? Computers simulate determinism; only <BR> the Tao is perfect. <BR> <BR> The rules of programming are transitory; only the Tao is <BR> eternal. Therefore you must contemplate the Tao before you <BR> receive enlightenment." <BR> <BR> "But how will I know when I have received enlightenment?" asked <BR> the novice. <BR> <BR> "Your program will then run correctly," replied the master. <BR> <BR> 4.3 <BR> A master was explaining the nature of the Tao to one of his <BR> novices, "The Tao is embodied in all software -- regardless of <BR> how insignificant," said the master. <BR> <BR> "Is the Tao in a hand-held calculator?" asked the novice. <BR> <BR> "It is," came the reply. <BR> <BR> "Is the Tao in a video game?" continued the novice. <BR> <BR> "It is even in a video game," said the master. <BR> <BR> "And is the Tao in the DOS for a personal computer?" <BR> <BR> The master coughed and shifted his position slightly. "The <BR> lesson is over for today," he said. <BR> <BR> 4.4 <BR> Prince Wang's programmer was coding software. His fingers <BR> danced upon the keyboard. The program compiled without an error <BR> message, and the program ran like a gentle wind. <BR> <BR> "Excellent!" the Prince exclaimed, "Your technique is <BR> faultless!" <BR> <BR> "Technique?" said the programmer, turning from his terminal, <BR> "What I follow is the Tao -- beyond all technique. When I first <BR> began to program I would see before me the whole program in one <BR> mass. After three years I no longer saw this mass. Instead, I <BR> used subroutines. But now I see nothing. My whole being exists <BR> in a formless void. My senses are idle. My spirit, free to work <BR> without a plan, follows its own instinct. In short, my program <BR> writes itself. True, sometimes there are difficult problems. I <BR> see them coming, I slow down, I watch silently. Then I change a <BR> single line of code and the difficulties vanish like puffs of <BR> idle smoke. I then compile the program. I sit still and let the <BR> joy of the work fill my being. I close my eyes for a moment and <BR> then log off." <BR> <BR> Prince Wang said, "Would that all of my programmers were as <BR> wise!" <BR> _________________________________________________________________ <BR> <BR> Maintenance <BR> Book Five <BR> _____________________________________________________ <BR> <BR> Thus spake the master programmer: <BR> <BR> "Though a program be but three lines long, <BR> someday it will have to be maintained." <BR> _____________________________________________________ <BR> <BR> 5.1 <BR> A well-used door needs no oil on its hinges. <BR> A swift-flowing stream does not grow stagnant. <BR> Neither sound nor thoughts can travel through a vacuum. <BR> Software rots if not used. <BR> <BR> These are great mysteries. <BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -