From: William Victor Mote Date: Tue, 1 Jul 2003 18:40:26 +0000 (+0000) Subject: Move some of the resolved "style" wiki contents to conventions.xml. X-Git-Tag: Root_Temp_KnuthStylePageBreaking~1366 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4412935e117e0676296a7895e767c73edbcad3a3;p=xmlgraphics-fop.git Move some of the resolved "style" wiki contents to conventions.xml. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196556 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/documentation/content/xdocs/dev/conventions.xml b/src/documentation/content/xdocs/dev/conventions.xml index c6a376e2b..320efbc47 100644 --- a/src/documentation/content/xdocs/dev/conventions.xml +++ b/src/documentation/content/xdocs/dev/conventions.xml @@ -12,26 +12,84 @@ Java Style

In order to facilitate the human reading of FOP source code, the FOP developers have agreed on a set of coding conventions. The basis of these coding conventions is documented in the Apache XML Project Guidelines, which requires that all Java Language source code in the repository must be written in conformance to Sun's Code Conventions for the Java Programming Language. -In addition, other conventions have been applied to the FOP project, which are summarized in the following table:

+In addition, the FOP developers have agreed to other conventions, which are summarized in the following table:

+ + + + + - - - + + + + + + + + + + + + + + + + + + + + + + +
Convention Rationale Enforced By
Every Java source file starts with the Apache licence header.Required by Apache.checkstyle
No tabs in content Programmers should not have to adjust the tab settings in their editor to be able to read the source code. checkstyle
Indentation of 4 spaces per levelMaximize readability.Not enforcedIndentation of 4 spaces per levelMaximize readability.Not enforced
Comments must be in EnglishTo avoid the need for everyone to learn all languages, English has become the standard language for many technology projects, and is the only human language that all FOP developers are expected to know.Not enforced
Fully qualify all import statements (no "import java.util.*")Claritycheckstyle
No underscores in variable names except for static finals.Upper/lower case distinctions can be made in all other variable names, eliminating the need for artificial word boundaries.checkstyle
Opening brace for a block should be on the same line as its control statement (if, while, etc.).Standardization, general preference.checkstyle

For developers that dislike these conventions, one workaround is to develop using their own style, then use a formatting tool like astyle (Artistic Style) before committing.

+
+ Checkstyle +

The java syntax checker "Checkstyle" is used to enforce many of the FOP coding standards. +The standards enforced through Checkstyle are documented in its configuration file (xml-fop/checkstyle.cfg). +The conventions defined in the configuration file are an integral part of FOP's coding conventions, and should not be changed without common consent. +In other words, the configuration file contains additional conventions that are not documented on this page, but are generally accepted as good style within the java community (i.e. they are the default behavior of checkstyle, which the FOP developers have decided to adopt de facto). +Any apparent contradiction between the configuration file and this document should be raised on the fop-dev mailing list so that it can be clarified.

+

To use the "checkstyle" target in FOP's build process, download the source from the Checkstyle web site, place checkstyle-all-*.jar in the lib directory and call "build checkstyle". Output (in the build directory) includes checkstyle_report.txt and checkstyle_report.xml. If you copy the file contrib/checkstyle-noframes.xsl from Checkstyle into FOP's root directory, you will also get an HTML report.

+

Checkstyle is probably most useful when integrated into your IDE. See the Checkstyle web site for more information about IDE plugins.

+
+
+ Java Best Practices +

The following general principles are a distillation of best practice expectations on the FOP project.

+ +