posts - 84, comments - 54, trackbacks - 0, articles - 0
             :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          Some good programming styles

          Posted on 2007-04-25 10:57 馬達+斯加 閱讀(215) 評論(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.
          主站蜘蛛池模板: 祥云县| 东乌| 英超| 汤阴县| 桃园市| 龙海市| 台东县| 安化县| 清涧县| 五寨县| 松潘县| 白玉县| 陆良县| 武鸣县| 北流市| 郧西县| 福州市| 库伦旗| 银川市| 博白县| 青岛市| 靖安县| 闸北区| 黑山县| 嘉黎县| 卢湾区| 商南县| 龙南县| 凯里市| 铜山县| 城固县| 芮城县| 高州市| 嘉峪关市| 长寿区| 谢通门县| 社会| 九台市| 鄂伦春自治旗| 淳安县| 余干县|