admin 管理员组文章数量: 1086019
2024年4月17日发(作者:键盘按键介绍)
此为英文版,英文好些的,可以看看英文。除此之外,例子也很详细,直观,
一看就懂。
大家看看可以提高自己的编程风格和交流代码。
Java Programming Style Guidelines
Version 6.1, March 2008
Geotechnical Software Services
Copyright © 1998 - 2008
This document is available at /development/
Table of Content
1 Introduction
o 1.1 Layout of theRecommendations
o 1.2 Recommendations Importance
o 1.3 Automatic Style Checking
2 General Recommendations
o 3.1 General Naming Conventions
o 3.2 Specific naming Conventions
4 Files
o 5.1 Package and Import Statements
o 5.2 Classes and Interfaces
o 5.3 Methods
o 5.4 Types
o 5.5 Variables
o 5.6 Loops
o 5.7 Conditionals
o 5.8 Miscellaneous
6 Layout and Comments
o 6.1 Layout
o 6.2 White space
o 6.3 Comments
7 References
5 Statements
3 Naming Conventions
1 Introduction
This document lists Java coding recommendations common in the Java development
community.
The recommendations are based on established standards collected from a number of
sources, individual experience, local requirements/needs, as well as suggestions given in [1],
[2], [3], [4] and [5].
There are several reasons for introducing a new guideline rather than just referring to the ones
above. Main reason is that these guides are far too general in their scope and that more
specific rules (especially naming rules) need to be established. Also, the present guide has an
annotated form that makes it easier to use during project code reviews than most other
existing guidelines. In addition, programming recommendations generally tend to mix style
issues with language technical issues in a somewhat confusing manner. The present
document does not contain any Java technical recommendations at all, but focuses mainly on
programming style.
While a given development environment (IDE) can improve the readability of code by access
visibility, color coding, automatic formatting and so on, the programmer should never rely on
such features. Source code should always be considered larger than the IDE it is developed
within and should be written in a way that maximize its readability independent of any IDE.
1.1 Layout of the Recommendations.
The recommendations are grouped by topic and each recommendation is numbered to make it
easier to refer to during reviews.
Layout for the recommendations is as follows:
n. Guideline short description
Example if applicable
Motivation, background and additional information.
The motivation section is important. Coding standards and guidelines tend to start "religious
wars", and it is important to state the background for the recommendation.
1.2 Recommendation Importance
In the guideline sections the terms must, shouldand canhave special meaning. A
mustrequirement must be followed, a shouldis a strong recommendation, and a canis a
general guideline.
1.3 Automatic Style Checking
Many tools provide automatic code style checking. One of the most popular and feature rich
one is Checkstyleby Oliver Burn.
Checkstyle is configured through an XML file of style rules which is applied to the source code.
It is most useful if it is integrated in the build process or the development environment. There
are Checkstyle plugins for all the popular IDEs available.
To use Checkstyle with the GeoSoft style rules below, use this configuration file:
geosoft_.
版权声明:本文标题:java 编程规范(Java Programming Style Guidelines) 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/b/1713292270a627927.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论