Programming Principles Summary 编程原则总结

来源:互联网 发布:php权限管理源代码 编辑:程序博客网 时间:2024/06/06 05:40

ProgrammingPrinciples Summary

编程原则总结

Programming Precept :

Methodsof a class are public .Function in a class are private.

                          一个类的方法是公用的,一个类中的函数是私有的。

Includeprecise preconditions and  postconditions with every program ,function ,and methodthat you write.编写的每个程序,函数和方法要包含准确的前置条件和后置条件

Alwaysname your classes ,variables and functions with the greatest care,and explainthem thoroughly最谨慎的选择类,变量和函数的名称并予以详细的解释.

Keepyour documentation concise but descriptive.                                              保持你的文档简练但是具可有描述性

Thereading time for programs is much more than the writing time.Make reading easyto do.阅读程序的时间比编写程序的时间多得多,使阅读更容易。

Don’tlose sight of the forest for its trees.不要只见树木不见森林

Useclasses to model the fundamental concepts of the program.使用类来模拟程序的基本概念。

Eachfunction should do only one task ,but do it well.每个函数应该仅仅只完成一个任务,但是要完成的好。

Eachclass or function should hide something.每个类或函数应该隐藏某些东西

Keepyour connections simple .avoid global variables whenever possible.保持连接简单,尽可能避免全局变量的使用

Nevercause side effects if you can avoid it .if you must use global variables asinput ,document them thoroughly.只要能够避免,切勿引起副作用。如果必须使用全局变量作为输入,则详细的将它们写入文档。

Keepyour input and output as separate functions ,so they can be changed easily andcan be custom tailored to your computing system将输入和输出作为独立的函数,使得它们易于修改并且能定制修改来适应计算机系统.

Thequality of test data is more important than its quantity.测试数据的质量比数量更重要。

Programtesting can be used to show the presence of bugs ,but never their absence.程序测试可用于说明bug的存在,而不能说明其不存在。

Fora large and important program ,more than half the work comes in the maintenancephase ,after it has been completely debugged ,tested ,and put into use.对于一个大型且重要的程序,超过一半的工作来自维护阶段,在它已被完全调试,测试并投入使用后。

Besure you understand your problem completely .If you must change  its terms ,explain exactly what you have done .确信你完全的理解了问题。如果必须改变其条件,则确切的解释所做的修改。

 Design the user interface with the greatestcare possible .A program’s success depends greatly on its attractiveness and easeof use.最精心地设计用户接口,程序的成功很大程度上是靠它的吸引力和易用性。

Donot optimize your code unless it is necessary to do so .Do not start tooptimize code until it is complete and correct .Most programs spend 90 percentof their time doing 10 percent of their instructions .Find this 10 percent andconcentrate your efforts for efficiency there.除非必要,不要优化代码。在代码完善和正确之前,不要开始优化代码。大多数程序将90%的时间花在10%的指令上,找出这10%,集中精力提高它的效率。

Keepyour algorithms as simple as you can. When in doubt ,choose the simple way.尽所能保持算法简单。当犹豫不决时,选择简单的方式。

Sometimespostponing problems simplifies their solution.有时延缓问题会简化解决方案。

Nevercode until the specifications are precise and complete.在需求说明准确和完善前不要编码

Actin haste and repent at leisure. Program in haste and debug forever.

Startingafresh is often easier than patching an old program.重新开始经常比给一个旧程序打补丁更简单。

Always plan to build aprototype and throw it away .You’ll do so whether you plan to or not.总是计划建立原型并丢弃它,不管是否计划都必须这样做
原创粉丝点击