The programmer made no reply.

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?'

'It will take one year,' said the master promptly.

'But we need this system immediately or even sooner! How long will it take if I assign ten programmers to it?'

The master programmer frowned. 'In that case, it will take two years.'

'And what if I assign a hundred programmers to it?'

The master programmer shrugged. 'Then the design will never be completed,' he said.

Book Four. Coding

'A well-written program is its own heaven; a poorly-written program is its own hell.'

Thus spake the master programmer

4.1

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.

4.2

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.

4.3

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.

4.4

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

Вы читаете The Tao Of Programming
Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату