[jsword-devel] coding conventions

DM Smith dmsmith at crosswire.org
Tue Oct 27 06:09:08 MST 2009

On Oct 27, 2009, at 8:32 AM, Manfred Bergmann wrote:

> Hi have a question about conventions.
> Java coding guideline is to have the brackets not in a new line.
> I've seen both in JSword but is it to have new line?

The JSword guideline is to have every { and } on a new line. This pre- 
existed my involvement.

The checkstyle task in the ant build will check for style issues.  
You'll need the jsword-support project to get this. We're using  
checkstyle 5.0 with a custom rule set at:

Alternatively, you can use that custom rule set and get a Checkstyle  
plugin for IntelliJ IDEA at:

Another useful task is the findbugs ant task.
Rather than an ant task, you can get it for IntelliJ IDEA as a plugin  
here: http://plugins.intellij.net/plugin/?id=3847

> Why are the instance variables declarations at the bottom?

This is another JSword style that was before I came to the project.
The reasoning is that instance variables are typically private and as  
such are not something that should be "up front", but rather buried as  
an implementation detail.
Class constants should be at the top.

The general pattern is that constructors should be first, then public  
methods and classes, protected and package protected methods and  
classes and finally private methods and classes.
> What is this // $NON-NLS-1 for?
> This i've seen nowhere else actually.

This is an Eclipse feature that has helped us in internationalization.  
It marks strings that do not need to be internationalized.
Ultimately, strings that should be internationalized should be put in  
resource files. We use Msg.properties for that.

In Him,

More information about the jsword-devel mailing list