Here we provide an overview of the coding standards employed in JPOX. If you want to work on JPOX or contribute code to JPOX you are expected to use these coding standards. We know everyone has their own preference but these are ours so you follow them or any contributed code will not be directly included as is They may differ from SUNs coding conventions but then those are the conventions of some US company and that doesn't mean that they are necessarily "the best", "the official" or any such title. These are ours, so best get used to it ;-).
If you are using Eclipse then we have an
XML Configuration to specify in Eclipse.
/**
* A sample source file for the code formatter preview
*/
package mypackage;
import java.util.LinkedList;
public class MyIntStack
{
private final LinkedList fStack;
public MyIntStack()
{
fStack = new LinkedList();
}
public int pop()
{
return ((Integer) fStack.removeFirst()).intValue();
}
public void push(int elem)
{
fStack.addFirst(new Integer(elem));
}
public boolean isEmpty()
{
return fStack.isEmpty();
}
}
/**
* Indentation
*/
class Example
{
int[] myArray = {1, 2, 3, 4, 5, 6};
int theInt = 1;
String someString = "Hello";
double aDouble = 3.0;
void foo(int a, int b, int c, int d, int e, int f)
{
switch (a)
{
case 0 :
Other.doFoo();
break;
default :
Other.doBaz();
}
}
void bar(List v)
{
for (int i = 0; i < 10; i++)
{
v.add(new Integer(i));
}
}
}
/**
* If...else
*/
class Example
{
void bar()
{
do
{
}
while (true);
try
{
}
catch (Exception e)
{
}
}
void foo2()
{
if (true)
{
return;
}
if (true)
{
return;
}
else if (false)
{
return;
}
else
{
return;
}
}
void foo(int state)
{
if (true)
{
return;
}
if (true)
{
return;
}
else if (false)
{
return;
}
else
{
return;
}
}
}
In this document we describe just a small set of guidelines. Our references are really worth a read and must be followed during JPOX development. |