"A well-written program is its own heaven; a poorly-written program is its own hell."
Thus spake the master programmer
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity.
A program should follow the Law of Least Astonishment . What is this law? It is simply that the program should always respond to the user in the way that astonishes him least.
A program, no matter how complex, should act as a single unit. The program should be directed by the logic within rather than by outward appearances.
If the program fails in these requirements, it will be in a state of disorder and confusion. The only way to correct this is to rewrite the program.
A novice asked the master: "I have a program that sometime runs and sometimes aborts. I have followed the rules of programming, yet I am totally baffled. What is the reason for this?"
The master replied: "You are confused because you do not understand Tao. Only a fool expects rational behavior from his fellow humans. Why do you expect it from a machine that humans have constructed? Computers simulate determinism; only Tao is prefect.
The rules of programming are transitory; only Tao is eternal. Therefore you must contemplate Tao before you receive enlightenment."
"But how will I know when I have received enlightenment?" asked the novice.
"Your program will then run correctly," replied the master.
A master was explaining the nature of Tao of to one of his novices, "The Tao is embodied in all software — regardless of how insignificant," said the master.
"Is the Tao in a hand-held calculator?" asked the novice.
"It is," came the reply.
"Is the Tao in a video game?" continued the novice.
"It is even in a video game," said the master.
"And is the Tao in the DOS for a personal computer?"
The master coughed and shifted his position slightly. "The lesson is over for today," he said.
Prince 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.
"Excellent!" the Prince exclaimed, "Your technique is faultless!"
"Technique?" said the programmer turning from his terminal, "What I follow is Tao — beyond all techniques! When I first began to program I would see before me the whole problem in one mass. After three years I no longer saw this mass. Instead, I used subroutines. But now I see nothing. My whole being exists in a formless void. My senses are idle. My spirit, free to work without plan, follows its own instinct. In short, my program writes itself. True, sometimes there are difficult problems. I see 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 my eyes for a moment and then log off."
Prince Wang said, "Would that all of my programmers were as wise!"
"Though a program be but three lines long, someday it will have to be maintained."
Thus spake the master programmer
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.
A manager asked a programmer how long it would take him to finish the program on which he was working. "I 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 lunch, he discovered the programmer asleep at his terminal. He had been programming all night.
A novice programmer was once assigned to code 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."
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?
"Let the programmer be many and the managers few — then all will be productive."
Thus spake the master programmer
When managers hold endless meetings, the programmers write games. When accountants talk of quarterly profits, the development budget is about to be cut. When senior scientists talk blue sky, the clouds are about to roll in.
Truly, this is not the Tao of Programming.
When managers make commitments, game programs are ignored. When accountants make long-range plans, harmony and order are about to be restored. When senior scientists address the problems at hand, the problems will soon be solved.
Truly, this is the Tao of Programming.
Why are programmers non-productive? Because their time is wasted in meetings.
Why are programmers rebellious? Because the management interferes to much.
Why are the programmers resigning one by one? Because they are burnt out.
Having worked for poor management, they no longer value their jobs.
A manager was about to be fired, but a programmer who worked for him invented a new program that became popular and sold well. As a result, the manager retained his job.
The manager tries to give the programmer a bonus, but the programmer refused it, saying, "I wrote the program because I thought it was an interesting concept, and thus I expect no reward."
The manager upon hearing this remarked, "This programmer, though he holds a position of small esteem, understands well the proper duty of an employee. Lets promote him to the exalted position of management consultant!"
But when told this, the programmer once more refused, saying, "I exist so that I can program. If I were promoted, I would do nothing but waste everyone’s time. Can I go now? I have a program that I’m working on."
A manager went to his programmers and told them: "As regards to your work hours: you are going to have to come in at nine in the morning and leave at five in the afternoon." At this, all of them became angry and several resigned on the spot."
So the manager said: "All right, in that case you may set your own working hours, as long as you finish your projects on schedule." The programmers, now satisfied, began to come in at noon and work to the wee hours of the morning.
Читать дальше