你对编程的“道”和“术”的理解( 四 )
3.3There 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?""An operating system," replied the programmer.The warlord uttered an exclamation of disbelief. "Surely an accounting package is trivial next to the complexity of an operating system," he said."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."The warlord of Wu nodded and smiled. "That is all good and well, but which is easier to debug?"The programmer made no reply.尝有程序员见于吴王。王问曰:“设计会计软件,设计操作系统,孰易?”
曰:“操作系统。”
王不之信,曰:“会计软件易于操作系统,诚然!”
曰:“非也。夫设计会计软件,程序员者,各色用户之中介也,其思多异。及其操作系统,程序员者,但求机器于思想之和谐也。此之谓设计操作系统易也。”
吴王颔而笑曰:“调试,二者孰易?”
程序员默而不应。
3.4A 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 it 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.御者见主程序员,以新应用之需求文档示之,问曰:“今有程序员五人,需时日几何?”
曰:“一年。”
“吾急需之!若有十人,几何?”
然曰:“二年。”
“百人若何?”
对曰:“万世。”
第四章 编码Thus spake the master programmer:"A well-written program is its own heaven; a poorly-written program is its own hell."师曰:“善程序者自善其身,不善程序者自毁其意。”
4.1A program should be light and agile, its subroutines connected like a strings of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little nor 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.程序者,轻盈捷巧,子程序者,累若串珠,贯之以精神。减一丝则少,增一分则多,循环、变量、结构皆为其恰。
推荐阅读
- 学图像处理有哪些不错的书推荐
- dart这编程语言现在发展怎么样了,语法与Java,c#很相似,甚至更简洁
- 应该怎样理解会员服务的法律性质
- 有点计算机基础的人想尽快找份编程的工作。哪种编程的工作最好找还需要学些啥
- 作为软件工程大二的学生,学习一般,编程一般,毕业后能干些啥
- 30岁的人生,想自学一门编程并从事,这个选择怎样呢
- 电子编程书可以边看边练习,价值大吗
- 读书读到3分之一的时候感觉很难理解,要不要继续
- 自学编程知识是自己啃书加实践好还是看视频加实践好好
- 马云说的大数据时代到底是,用到啥技术,如果想要学习大数据技术,要学习哪些基础的东西要先会编程么
