Index: xdocs/code-standards.xml =================================================================== RCS file: /home/cvspublic/jakarta-jetspeed/xdocs/code-standards.xml,v retrieving revision 1.11 diff -u -r1.11 code-standards.xml --- code-standards.xml 26 Jul 2003 04:36:58 -0000 1.11 +++ code-standards.xml 25 Aug 2003 22:38:48 -0000 @@ -19,48 +19,49 @@
- -
+
As more developers submit code to Jetspeed, it is important that we all adhere
to the same types of coding styles. This document was created to provide a
set of guidelines for future development.
+
A Java style checker, checkStyle, is part of the build process. This should aid
in the development of readable code. Jetspeed currently works with version 2.4 of
the checkStyle. For more information see http://checkstyle.sourceforge.net.
@@ -82,7 +83,7 @@
+
Please use spaces within method parameter lists:
-Use of brackets. Some developers have personal a preference to
-how they place brackets within their source code:
+
+Use of brackets. Some developers have personal a preference
+to how they place brackets within their source code:
+
Please choose whatever style you want for new files but you should
maintain the existing style of source you wish to modify.
+
If you have a method with multiple parameters, separate them across
multiple lines.
+
Testing is a great way to detect and prevent bug. By automating the
- testing process, the test are easy to run and identify failures.
+ testing process, the tests are easy to run and identify failures.
Jetspeed uses the testing facilities built into Ant, primarily Cactus
and JUnit.
+
The required tests are made up of Cactus and JUnit test used to
insure working, and hopefully bug free, code.
+
These are unit tests grouped logically. In some case their is a
testing hierarchy. In the case of unittest-security. It is composed
of the security implementation test, i.e. unittest-security-registry
and unittest-security-turbine.
+
Below is just a sample of Unit Test Groups available
+
Cactus testing is used when rundata is required. The test usually
involve generating a URL in beginTestName(). The URL is
passed to a test, named testTestName(), running on a web
server started by Cactus.
- The execution of Cactus test are dependent on the version of the
- servlet engine. Currently their are two place in build.xml to add
+
+ The execution of Cactus tests are dependent on the version of the
+ servlet engine. Currently there are two place in build.xml to add
Cactus test.
+
Example of Cactus test can be found in
+
Documentation for Cactus can be found at
http://jakarta.apache.org/cactus
+
JUnit testing is simpler the Cactus testing, in part because the do
not require a web server. These test generally test small functional
units, like reading a file into a data structure. Turbine services
also be tested with JUnit test, see
+
Example of JUnit test can be found in
+
Documentation for JUnit can be found at
http://junit.org
+
Enter the property in the language propery file,
+
The following code will place the localized, based on the user's
language, value into the variable
+
The following code will center the localized, based on the user's
language, value on the resulting portlet.
+
Logging is very useful for diagnosing and resolving problems. As a general rule, all exceptions should be logged,
and done so in the following fashion:
+
Since the new logging scheme uses Log4J, the penalty of log statements that are not actually activated, such as debug,
- is negligable. However, if your log message uses String concatenation ("+"), avoid loads of objects to be garbage collected by always
+ is negligible. However, if your log message uses String concatenation ("+"), avoid loads of objects to be garbage collected by always
checking if the particular level you are logging is enabled, by calling eg.
+
Debug logging is intended for development and problem determination. It
is not intended for use in a "normal" production environment. Therefore do not depend on important
- information to be logged using debug. Do, however, add a reasonable about of debug logging in your code, expecially where
+ information to be logged using debug. Do, however, add a reasonable about of debug logging in your code, especially where
robustness checks fail and "strange" things happen. This makes bug hunting a lot easier!
+
The following code snippet shows how to use the new logging features.
+
All changes posted by non-committers should be submitted (and accepted) in form
of patches. Patches can be created from root of the project using the this command:
+
A properly structured patch can be applied using the cvs patch utility from the project's root as follows:
-
+
+
+
+
+ use @see tags to point Javadoc back to the interface method. You should then
+ keep all your Javadoc defined in the interface so that it isn't duplicated in
+ your implementation.
+
+ and Exceptions (@throws)
+
+ which defines what this package does.
+
+ to the @author tags. Please also include your e-mail address.
+
+
Test and be
+ The name of test class should start with Test and be
located in the package it test.
be JUnit tests, Cactus tests, or both.
+ and/or changes to detect what is being fixed, i.e. modify the
+ test to detect the problem then fix the problem. The updated
+ test(s) should confirm you fixed the problem.
cvs checkout, after a
- cvs update, and before a cvs commit.
+ cvs checkout, after a cvs update,
+ and before a cvs commit.
Required Tests
-
Unit Test Groups
-
@@ -237,38 +240,38 @@
org.apache.jetspeed.test.BasicSecurityTest
and org.apache.jetspeed.template.TestJetspeedLink.
org.apache.jetspeed.services.registry.TestMarshallRegistry.
org.apache.jetspeed.services.registry.TestMarshallRegistry
and org.apache.jetspeed.template.TestJetspeedLinkFactory.
org.apache.jetspeed.modules.localization.JetspeedProperty_
language.properties. All properties should be
@@ -293,7 +296,7 @@
]]>
title.
logger.error("What went wrong", ex);
@@ -324,17 +327,17 @@
Do not log exceptions like this: logger.error(ex); Whenever you want to log a Throwable, it should be the
second parameter of your fatal/error/warn/info/debug call.
logger.isDebugEnabled().
This is not necessary for logging simple Strings. Also, if you are building your message by concatenation, use
StringBuffer and .append() instead of String and "+". Your code will be more efficient and produce less garbage.
Do NOT use levels above debug, such as info, for debug messages!
+
+
+ current directory structure. For example do no put documentation
within the ./src/java directory.
+ within Jetspeed which describe an internal problem should extend
org.apache.jetspeed.util.JetspeedException (see PortletException.java)
cvs diff -u [file to be patched]cvs diff -u cvs diff -u src/java/org/apache/jetspeed/services/registry/CastorRegistryService.java
+ And don't forget to run the unit tests before submitting a patch.
+
- patch -i [patch file name] -p0