Programming Principles summary

来源:互联网 发布:淘宝申请售后退款 编辑:程序博客网 时间:2024/06/05 03:06

ProgrammingPrinciples Summary

u  Convention :Methods of a class are public .Function in a class areprivate.

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

Programming Precept :Includeprecise(准确的) preconditions and postconditions  (前置条件和后置条件)with every program ,function ,and methodthat you write.

Alwaysname your classes(类),variables(变量)and functions(名称)with the greatest care(认真谨慎的),andexplain them 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 (副作用)ifyou can avoid it .if you must use global variables(全局变量)as input ,document themthoroughly(详细的将他们写入文档).

Keepyour input and output as separate(独立的)functions ,so they can be changed easily and can be custom tailored to yourcomputing 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.

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 to optimize codeuntil it is complete and correct .Most programs spend 90 percent of their timedoing 10 percent of their instructions(指令) .Find this 10 percent andconcentrate your efforts for efficiency(效率) there.

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.

原创粉丝点击