国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Good Java Style: Part 1

2019-11-18 14:43:05
字體:
來源:轉載
供稿:網友

  Good java Style: Part 1
By Thornton Rose

IntrodUCtion
Having worked as a software developer and consultant for many years, I have seen a large amount of code in a variety of PRogramming languages. It has run the gamut from elegant to ugly, and unfortunately much of it has been ugly. I hope to persuade you, and my fellow developers, that we should give as much attention to the style of our code as we give to the user interface and other visible parts of an application. In this the first part of a two part series, I eXPlain why we should care about how our code looks and illustrate some general elements of good Java style.

Why Style Matters
Even though Java is used to write programs rather than prose, it is still used to express thoughts and ideas. And, in addition to conveying information, those thoughts and ideas must actually do something. Worrying about good style may seem like a waste of time, but it behooves us to write our code such that the thoughts and ideas it expresses are exceptionally clear.

Here are several reasons for using good style [from "Java Code Conventions," Sun Microsystems]:


80% of the lifetime cost of a software product goes to maintenance.
Hardly any software is maintained for its whole life by the original author(s).
Using good style improves the maintainability of software code.
If the source code is shipped with the software, it should be as well-packaged, clean, and professional as the rest of the product.

Writing code with good style also provides the following benefits:


It improves the readability, consistency, and homogeneity of the code, which makes it easier to understand and maintain.
It makes the code easier to trace and debug, because it's clear and consistent.
It allows you to continue more easily where you or another programmer stopped, particularly after a long period of time.
It increases the benefit of code walkthroughs, because the participants can focus more on what the code is doing.

General Guidelines
Writing Java with good style is not hard, but it does require attention to detail. Here are some general guidelines to follow:


Make the code clear and easy to read.
Make the code consistent.
Use obvious identifier names.
Logically organize your files and classes.
Have only one class per file (not including inner classes).
Use a maximum line width of 80-90 characters.
Use whitespace and/or other separators judiciously.
Use spaces instead of tabs for indentation.


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 连州市| 古蔺县| 萨嘎县| 沈丘县| 桃园县| 台南市| 沙坪坝区| 新宁县| 河南省| 科技| 个旧市| 英山县| 溆浦县| 正镶白旗| 祁门县| 平利县| 连江县| 淳化县| 仙游县| 北碚区| 怀化市| 济南市| 鄂尔多斯市| 嘉鱼县| 弥渡县| 邢台市| 通许县| 方山县| 武义县| 安图县| 香河县| 利津县| 镇雄县| 贞丰县| 宣恩县| 安新县| 五家渠市| 黑龙江省| 普洱| 葫芦岛市| 仙桃市|