On Nov 29, 2006, at 1:01 PM, Raymond Feng wrote:

Hi,

I had promised to look into an Eclipse template for code formatting. Sorry for the long turnaround.

Here's the Eclipse java code formatter that I customized. Please use this and let me know if there are cases where formatter produces ugly code that needs to be fixed. You can import this into eclipse to format your code. I also attach a sample code from Tuscany formatted by the template.

It seems that we all agree that it is important to follow a fairly consistent coding style. We also agree that it is important to allow developers to choose the IDE that they are most comfortable with. It looks like the popular IDEs are IDEA and Eclipse.

It would have been ideal if all IDEs conformed to Checkstyle rules which is used in maven build to audit coding style. However, this is not the case. It seems that IDEA is able to format the code in accordance with checkstyle, but Eclipse cannot reach 100% compliance. Eclipse formatter does however cover most cases. For the areas of mismatch between IDEs, perhaps we could consider relaxing some of the checkstyle rules to ensure both IDEs can handle the same rules. This will also help us have a consistent coding style across the board no matter which IDE is used. We can do this overtime as we learn more what the differences are.

Now, here is what I understand as being the checkin guidelines. We run "mvn -Psourcecheck" to ensure:

1. Any PMD violations should be fixed because they hint potential bugs.

* Possible bugs - empty try/catch/finally/switch statements
* Dead code - unused local variables, parameters and private methods
* Suboptimal code - wasteful String/StringBuffer usage
* Overcomplicated expressions - unnecessary if statements, for loops that could be while loops
* Duplicate code - copied/pasted code means copied/pasted bugs

2. The code is conforming to the checkstyle rules.

If yes, we can add this as guideline to our website page under coding guidelines (http://incubator.apache.org/tuscany/ codeguidelines.html).

+1. IntelliJ is not an issue with the checkstyle template, so we can put that aside. For Eclipse, my understanding (I don't use it) is that there is one problem with array initialization and there may be a few other random issues lurking. My preference would be to deal with issues as they arise, relaxing checkstyle if necessary. For the array problem, if someone wants to take a stab at relaxing it they should, or, since it only occurs one time in about 25,000 lines of code, we just fix it manually - it doesn't matter to me.

Jim


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to