4.1
A program should is light and agile, its subroutines connected like a strings of pearls. The spirit and intent of the program should is retained throughout. There should is neither too little nor too much, neither needless loops nor useless variables, neither lack of structure n or overwhelming rigidity.
A program should be brisk and free, and its sub process is like a string of pearls strung in a thread. Throughout, the goal is clear. One byte is too long, one byte is too short. There are neither unnecessary loops nor variables that are not referenced, neither lack of structure nor rigidity.
A program should follow the
least astonishment. What is this? It is simply this program should always respond to the user in the way that astonishes him.
A program should follow ' the principle of least surprise ', what is ' the principle of least surprise '? This means that a program should minimize the user's surprise.
A program, no matter how to complex, should act as a single unit. The program should is directed by the logic within rather than by outward.
No matter how complex a program may be, it should be a single whole. The program is guided by its internal logic rather than its appearance.
If The program is fails in these requirements, it'll be in a state of disorder and confusion. The ' only way to correct ' to rewrite ' program.
If a program does not meet the needs, it will be in a state of chaos and disorder. The only way out is to rewrite the program.
4.2
A novice asked the master: I have a program of that sometimes runs and sometimes aborts. I have followed the rules of programming, yet I am totally baffled. What is the reason for this?
A beginner asked the master: "One of my programs is sometimes normal and sometimes not normal." I have completely followed the rules of programming, and I am completely confused by it, what is the cause of this? ”
The master replied: "You are confused because you don't understand the Tao." Only a fool expects rational behavior the humans of his fellow. Why do you expect it to machine that humans have constructed? Computers simulate determinism; Only the Tao is perfect.
The master said: "You are confused because you do not understand the Tao." Only a fool can believe that the result of being taken for granted is to follow what others say. Why do you have to take the consequences from a machine constructed by humans? The computer is only the product of determinism, and only the Tao is perfect.
The rules of programming are transitory; Only the Tao is eternal. Therefore you are must contemplate the Tao before you receive enlightenment. "
Any programming rule is only suitable for a particular situation, and only the Tao is immutable. So you have to think before you are guided. ”
"But How would I know when I have received enlightenment?" asked.
"But how do I know when I will be guided?" ”
"Your program would then run correctly," replied the master.
"When your program is running correctly." Said the master.
4.3
A Master was explaining the nature of the Tao to one of his novices, "The Tao are embodied in all software--regardless of How insignificant, "said the master."
The novice asked the master to explain the "Tao nature". The master said: "Tao exists in any software-no matter how meaningless the software is."
"Is the Tao in a hand-held calculator?" asked the novice.
"Is it in the hand-held computational clamour?" "The beginner asked.
"It is," came the reply.
"Yes,"
"Is the Tao in a video game?" continued the novice.
"Also in the game machine?" , the beginner asked.
"It is even in a video game," said the master.
"Yes, even in the game machine," he said. Said the master.
"and is" the Tao in the DOS for a personal computer? "
"Does it exist in the dos of a personal computer?" ”
The master coughed and shifted his position slightly. "The lesson is over for today," he said.
The master coughed and moved a little, saying, "Today's lesson is here."
4.4
Price Wang ' s programmer was coding software. His fingers danced upon the keyboard. The program compiled without an error message, and the program ran like a gentle wind.
# # # #编程大师编写软件时, fingers are flying fast on the keyboard. The program compiles without an error message, and the program runs like a gust of wind.
excellent! "The price exclaimed," Your technique is faultless! "
It's wonderful! Your skills are impeccable.
"Technique?" said the programmer, turning from his terminal, "What I follow are the Tao--beyond all technique." When I-i-i-began to program I would, before me the whole program in one mass. After the three years I no longer saw this mass. Instead, I used subroutines. But now I do nothing. My whole being exists in a formless void. My senses are idle. My spirit, work without a and follows its own instinct. In short, my program writes itself. True, sometimes there are difficult problems. I them coming, I slow down, I watch silently. Then I Change a single line of code and the difficulties vanish like puffs of idle smoke. I then compile the program. I sit still and let the joy of the work fill my being. I close me eyes for a moment and then log off. "
Skills The master turned around and said, "I am following the Tao--it is beyond all skill." When I started programming I saw a whole chunk of the program, and three years later I saw the sub process. Now I can't see anything. My whole existence is without any form of nothingness. I feel very relaxed, in short, actually my program is writing, sometimes I see some problems, I see them, I stopped to observe them silently, and then I changed a line of code, the problem is like a puff of smoke. Then I compile the program. Sit there and enjoy the joy of work. I closed my eyes for a while and then quit the system.
Price Wang said, "Would and all of my programmers were as wise!"
"When will my programmers be able to achieve this?"
Mainteance
Book Five
Thus spake The Master programmer:
The Master programmer says:
"Though a program is but three lines long, someday it would have to be maintained."
"Even if a program has only three presidents, one day it needs to be maintained."
5.1
A well-used door needs no oil in its hinges.
A swift-flowing Steam does no grow stagnant.
Neither sound nor thoughts can travel through a vacuum.
Software rots if not used.
Frequently used doors do not need to be oiled in the door shaft.
The flow of things will not stagnate.
Water does not rot, never worm-eaten. --Wang Lei
Neither sound nor thought can spread in a vacuum.
Software does not need to decay.
These are great mysteries.
5.2
A manager asked a programmer how long it would take him to finish the "program" on which him was working. "I'll be finished tomorrow," the programmer promptly replied.
The manager asked the programmer how long it would take to finish his project. Tomorrow
"I would have you are being unrealistic," said the manager. "Truthfully, how long would it take?"
"It's so irrelevant, honestly, how long?" he asked. ”
The programmer thought for a moment. "I have some features that I wish to add." This is take at the least two weeks, "he finally said.
The programmer thought about it. "There are some new features to add, maybe at least two weeks." ”
"Even that are too much to expect," insisted the manager, "I'll be satisfied if your simply tell me when the" Mplete. "
"Even if two weeks is too much to say, when you just tell me that the program is done." ”
The programmer agreed to this.
Several years slated, the manager retired. On the way to his retirement lunch, he discovered the programmer in his asleep. He had been programming all night.
A few years later, the manager had retired, and at his lunch, he found that the programmers were asleep at his terminal and he was programming all night.
5.3
A novice programmer is once assigned to code a simple financial package.
A beginner is required to write a financial software.
The novice worked furiously for many days, but as his master reviewed his program, and he discovered that it contained a SCR Een editor, a set of generalized graphics routines, and artificial intelligence interface, but not the slightest mention O F anything financial.
He worked frantically for many days, but his supervisor looked at his program and found that it wrote an editor, a graphics assembly, and an artificial intelligence interface, but couldn't see anything related to finance.
When the master asked is about this, the novice became indignant. "Don" is so impatient, "he said," I'll put the financial stuff in eventually. "
When the supervisor asked for an explanation, the programmer was enraged: "You are too impatient, I will write the financial part at the end." ”
5.4
Does a good farmer neglect a crop he has planted?
Does a good teacher overlook even most humble?
Does a good father allow a single child to starve?
Does a good programmer refuse to maintain his code?
A good farmer doesn't care about his crops.
A good teacher does not care for even the worst student.
A good father won't starve any of his children.
A good programmer should not refuse to defend his program.
Management
Book Six
Thus spake The Master programmer:
The Master programmer says:
"Let the programmer is many and the managers few-then all'll be productive."
"Increase the number of programmers, reduce managers-so they can improve efficiency." "
6.1
When managers hold endless meetings, the programmers write games. When accountants talk of quarterly profits, the development budget are about to was cut. When senior scientists talk blue sky, the clouds are is about to roll in.
When managers are busy with endless meetings, programmers are writing games. Finance executives will be cut when they talk about quarterly profits. As the old scientist talked about the blue sky, the clouds flocked in.
Truly, this isn't the Tao of programming.
This is not the way to program.
When managers make commitments, game programs are ignored. When accountants make long-range plans, the harmony and order are the about to is restored. When senior scientists to the problems at hand, the problems'll soon be solved.
Managers do not include games when assigning tasks, and when accountants make long-term plans, they should be exhaustive and happy. Scientists ask a question and it will be solved quickly.
Truly, this is the Tao of programming.
This is the way of programming.
6.2
Why are programmers non-productive? Because their is wasted in meetings.
Why programmers are inefficient because they waste their time on meetings.
Why are programmers rebellious? Because the management interferes too much.
Why is it difficult for programmers to manage? Because the manager has too much intervention.
Why are the programmers resigning one by one? Because they are burnt out.
Why do programmers resign one after another because they are tired.
Have worked for poor management, they no longer value their jobs.
Working under bad management, they don't enjoy the fun of work.
6.3
A manager is about to is fired, but a programmer who worked for him invented a new program that became popular and sold W Ell. As a result, the manager retained his job.
A manager will be fired, but one of his programmers has written a popular software and is booming. So the manager saved his job.
The manager tried to give the programmer a bonus, but the programmer refused it, saying, "I wrote the program because I th Ough It is an interesting concept, and thus I expect no reward. "
The manager gave the programmer a dividend, but the programmer refused, saying: "I wrote the program because it was fun to write the program, so I didn't want to get the money."
The manager, upon hearing this, remarked, "This programmer, though he holds a position of small esteem, understands OK t He proper duty of employee. Lets promote him to the exalted position of management consultant! "
"The programmer, no matter where he is now, can understand the job of an employee," the manager said. We have to promote him as a management consultant.
But when told this, the programmer once more refused, saying, "I exist so I can program." If I were promoted, I would do nothing but waste everyone's time. Can I go now? I have a program of that I ' m working one.
The programmer once again refused, he said: "I am a programmer so I can program, if I was promoted, besides wasting other people's time nothing can do, now I can go?" I still have a program that I haven't finished writing. ”
6.4
A Manger went to he programmers and told them: "As regards to your work hours:you-are going to have to come in ' at nine I n the morning and leave at five in the afternoon. At this, all of them became angry and several resigned on the spot.
The manager said to the programmer, "Your work time is 9 O ' Day in the morning to noon." "And all the programmers are dissatisfied.
So the manager said: "All right, in which case your may set your own working hours, as long as your finish your projects on S Chedule. " The programmers, now satisfied, began to come in a noon and work to the wee hours.
The manager added: "Well, it's up to you, as long as you can finish the task on time." "The programmers are satisfied, they work at noon and have been working until the wee hours of the morning."
Corporate Wisdom
Book Seven
Thus spake The Master programmer:
The Master programmer says:
"You can demonstrate A's for a corporate executive, but can ' t make him computer."
###
"You can demonstrate a program to a company executive, but you can't make his computer look like a human." ”