posts - 63, comments - 43, trackbacks - 0, articles - 0
   :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

Some good programming styles

Posted on 2007-04-25 10:57 马达+斯加 阅读(111) 评论(0)  编辑  收藏 所属分类: My life recorder
From <A Programming Style for Java> by Paul Haahr.
 

Choose a good name: The reason that you can't pick a good name is that you don't understand enough what you are trying to say, or what you are going to do.

Be consistent: Of course, which variations are purposeless and which consistencies are foolish is a subjective matter.

Comment appropriately: If no question would be asked by the reader, there is no purpose in answer it. A comment which doesn't answer any questions is probably superfluous.

Be a chameleon: When you are dropped into a piece of existing code, don't rewrite it all in your own style.

Use consistent naming conventions.

User names you can pronounce.

Don't use abbreviations: unless everyone knows that, e.g. URL, EJB

Don't subclass concrete classes.

Keep classes, fields, and methods private until they are needed elsewhere.

Use final for fields which shouldn't change.

Make all non-final fields private: Use setter and getter to control the fields.

Each method should do one thing.

Smaller methods are easier to understand.

Create new variables rather than reassigning old ones.

Don't modify parameter variables.

Don't use exceptions for normal control flow.

标题  
姓名  
主页
验证码 *  
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
 
成果网帮您增加网站收入
 
相关链接:
网站导航: