Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [che-dev] Che developers formatting rules for Java

I would start with reasonable Coding Guidelines. It should be short and memorable.

The one we have https://github.com/eclipse/che/wiki/Coding-Guidelines is nice but huge and so quite useless in practice.
Something like this https://github.com/Microsoft/vscode/wiki/Coding-Guidelines is better, I would make something like this by size or even shorter, like no more than 10 *must have* items, considering else as a *preferences*. I believe it is quite enough to make the code respectfully formatted.

This way every Contributor is able and obliged to learn, remember the rules and setup his tool/formatter according to it (of course Che/Codenvy should stick the rules by default).
And Code Maintainer reviewing PR is able to easily recognize bad formatting, reject it and refer author to this guide.

Of course it is nice to have (and we already have some) settings for popular IDEs'/tools formatters but the most important those rules should be described in plain English and be short/easy enough to read and apply.
   
 

Gennady Azarenkov - @ codenvy.com


On Wed, Mar 29, 2017 at 12:32 PM, Florent Benoit <fbenoit@xxxxxxxxxxx> wrote:
about #1, the only common tool across all IDE is maven
So I should say that we should have a maven plugin allowing to format the code (the same code convention could be used with Eclipse IDE, IntelliJ, Eclipse Che, another IDE) but at the end we could still use maven to check or format.

about #2, I would avoid any "developer's touch". Formatter is the rule. (we can complain on the format but once it is pick-up, it should be applied without exceptions)
because "he choice of the developer to make the code easier to read" is subjective. Some developers will like in one line, some on separate lines while the formatter will always be the same.


Florent

On Wed, Mar 29, 2017 at 10:51 AM, Sun Tan <sutan@xxxxxxxxxx> wrote:
I'd like to come up with some discussion we hard during reviews: https://github.com/eclipse/che/pull/4556/files/ba9e3984575c49f8f39a56db1df2e07b53786b3e#diff-ab312e4ea4cd0eee68fe53472bab93e1 

1. What tool to use to format code in Java ?
2. Usage of // to force Carriage return in some case

# 1. Some are using Intellij, the others Eclipse IDE and some others are using Eclipse Che as IDE.
For me, it makes sense to have a common formatter tool whatever the IDE we are using. It may also work from the command line and should be opensource. It should be possible to format part of the file. It should support Java files at least.
At the moment I use Che to code on Che so if someone has a formatter tool that meets all the previous requirements, I can take it ... otherwise if there isn't such a tool we should all use Che formatter to format our code :)

# 2. Usage of // to force Carriage return in some case
I had some questions about trailling // that I use to force cariage return when the formatter doesn't want to. The purpose is to avoid someone else that run a formatter to loose the carriage return that was there originally. I think this is the choice of the developer to make the code easier to read and to choose wether a line of code should be break into 2 line of code or not. Pretty much like when we add \ at the end of a bash script or Dockerfile.

--
Sun Tan
Senior Software Engineer
Eclipse Che @ Red Hat

_______________________________________________
che-dev mailing list
che-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/che-dev




--
Florent Benoit // Codenvy

_______________________________________________
che-dev mailing list
che-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/che-dev



Back to the top