You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafodion.apache.org by Venkat Muthuswamy <ve...@esgyn.com> on 2018/06/04 18:26:21 UTC

Standardize on java code style

Hi,

Given that many contributors are touching same java files and using their own editors of choice, it becomes difficult to review PRs when git reports large change when mismatch in tabs vs spaces.

Can we standardize on the java code style using the google java code style? There are plugins for eclipse and IntelliJ IDEs.
We start using these on any new files we touch going forward.

https://github.com/google/google-java-format
https://google.github.io/styleguide/javaguide.html

For eclipse, You can download the plugin jar and copy it to your eclipse/drop-ins folder. Restart eclipse and then set your java formatter implementation to google-java-format in Window > Preferences > Java > Code Style > Formatter > Formatter Implementation

Comments ?

Venkat

答复: Standardize on java code style

Posted by "Ma, Sheng-Chen (Aven)" <sh...@esgyn.cn>.
Hi all:
I agree with haolin's 4 white spaces indentation, for java code, I import google & hbase formatter plugin into eclipse, both formatters use 2 spaces indentation, it may dizzy when there have a lot of nests, such as  'if...else , while , for' ect.

Regards,
Aven


-----邮件原件-----
发件人: Song, Hao-Lin <ha...@esgyn.cn> 
发送时间: 2018年6月8日 11:25
收件人: dev@trafodion.apache.org
主题: 答复: Standardize on java code style

Hi

I think we could standardize our code style from indentation. Now, some old code uses tabs while some developers uses 3、4 or 8 white spaces as indentation. It is troublesome to align the format every time, loool.
Beside, 4 white spaces is my favorite because it is neither too long nor too short.

Best,
宋昊霖 (Haolin Song)

What doesn’t kill you make you stronger

-----邮件原件-----
发件人: Qifan Chen <qi...@esgyn.com> 
发送时间: 2018年6月8日 2:23
收件人: dev@trafodion.apache.org
主题: Re: Standardize on java code style

If we adopt Google style strictly, then there may be differences in naming the class data members, in a way  not compatible with our C/C++ coding conversion.  For example, we normally suffix a data member with '_', which is not the case with the Google style, available here https://google.github.io/styleguide/javaguide.html#s5.3-camel-case.  In Google style, the naming conversion for data members are as follows.


Non-constant field names (static or otherwise) are written in lowerCamelCase.


These names are typically nouns or noun phrases. For example, computedValues or index.


5.2.6 Parameter names


Parameter names are written in lowerCamelCase.


One-character parameter names in public methods should be avoided.


5.2.7 Local variable names


Local variable names are written in lowerCamelCase.


Even when final and immutable, local variables are not considered to be constants, and should not be styled as constants.



In addition, the # of white space characters to indent a new block of code or a switch statement is 2, and tabs should not be used to indent blocks etc.


Sounds like we may need to either follow the Google style completely, or follow it in principle but allow a slight deviation from it, such as suffix data members  with '_'.  I personally do not use tabs for indentation and put 3 white characters before the start of a new block.


Thanks --Qifan

________________________________
From: Selva Govindarajan <se...@esgyn.com>
Sent: Thursday, June 7, 2018 11:53:19 AM
To: dev@trafodion.apache.org
Subject: RE: Standardize on java code style

Are there any other guidelines for contributors who use neither of these IDE or any IDE at all?  In my opinion, 8 spaces seem to be a large indentation that would take the code away from the screen.  Can these plug-ins be configured with smaller number of spaces.

Selva

-----Original Message-----
From: Hans Zeller <ha...@esgyn.com>
Sent: Thursday, June 7, 2018 9:29 AM
To: dev@trafodion.apache.org
Subject: RE: Standardize on java code style

+1 on Venkat's proposal.

The Google style seems reasonably compatible with what we have already, both in Java and in C++.

Here are a few guidelines that should help avoiding such large differences, whether we adopt the Google style or not:

- Don't format entire files, especially not if there is not a common agreed upon style
- Don't insert any tabs into source files (part of Google style)
- For those tabs that unfortunately are in the code, use 8 spaces as the width, as most simple tools (vi, github.com, emacs, Notepad, BeyondCompare, etc.) do

To Avinash's question: Yes, these are Maven projects.

Thanks,

Hans

-----Original Message-----
From: Avinash Dongre <av...@ampool.io>
Sent: Wednesday, June 6, 2018 10:38 PM
To: dev@trafodion.apache.org
Subject: Re: Standardize on java code style

I have not seen the java code, is it maven based project ??


If java project is converted into gradle, then it has spotless plugin which while building the code fixes the code style.



Thanks

Avinash


________________________________
From: Venkat Muthuswamy <ve...@esgyn.com>
Sent: 04 June 2018 23:56:21
To: dev@trafodion.apache.org
Subject: Standardize on java code style

Hi,

Given that many contributors are touching same java files and using their own editors of choice, it becomes difficult to review PRs when git reports large change when mismatch in tabs vs spaces.

Can we standardize on the java code style using the google java code style? There are plugins for eclipse and IntelliJ IDEs.
We start using these on any new files we touch going forward.

https://github.com/google/google-java-format
GitHub - google/google-java-format: Reformats Java source ...<https://github.com/google/google-java-format>
github.com
README.md google-java-format. google-java-format is a program that reformats Java source code to comply with Google Java Style.. Using the formatter from the command-line ...



https://google.github.io/styleguide/javaguide.html

For eclipse, You can download the plugin jar and copy it to your eclipse/drop-ins folder. Restart eclipse and then set your java formatter implementation to google-java-format in Window > Preferences > Java > Code Style > Formatter > Formatter Implementation

Comments ?

Venkat

答复: Standardize on java code style

Posted by "Song, Hao-Lin" <ha...@esgyn.cn>.
Hi

I think we could standardize our code style from indentation. Now, some old code uses tabs while some developers uses 3、4 or 8 white spaces as indentation. It is troublesome to align the format every time, loool.
Beside, 4 white spaces is my favorite because it is neither too long nor too short.

Best,
宋昊霖 (Haolin Song)

What doesn’t kill you make you stronger

-----邮件原件-----
发件人: Qifan Chen <qi...@esgyn.com> 
发送时间: 2018年6月8日 2:23
收件人: dev@trafodion.apache.org
主题: Re: Standardize on java code style

If we adopt Google style strictly, then there may be differences in naming the class data members, in a way  not compatible with our C/C++ coding conversion.  For example, we normally suffix a data member with '_', which is not the case with the Google style, available here https://google.github.io/styleguide/javaguide.html#s5.3-camel-case.  In Google style, the naming conversion for data members are as follows.


Non-constant field names (static or otherwise) are written in lowerCamelCase.


These names are typically nouns or noun phrases. For example, computedValues or index.


5.2.6 Parameter names


Parameter names are written in lowerCamelCase.


One-character parameter names in public methods should be avoided.


5.2.7 Local variable names


Local variable names are written in lowerCamelCase.


Even when final and immutable, local variables are not considered to be constants, and should not be styled as constants.



In addition, the # of white space characters to indent a new block of code or a switch statement is 2, and tabs should not be used to indent blocks etc.


Sounds like we may need to either follow the Google style completely, or follow it in principle but allow a slight deviation from it, such as suffix data members  with '_'.  I personally do not use tabs for indentation and put 3 white characters before the start of a new block.


Thanks --Qifan

________________________________
From: Selva Govindarajan <se...@esgyn.com>
Sent: Thursday, June 7, 2018 11:53:19 AM
To: dev@trafodion.apache.org
Subject: RE: Standardize on java code style

Are there any other guidelines for contributors who use neither of these IDE or any IDE at all?  In my opinion, 8 spaces seem to be a large indentation that would take the code away from the screen.  Can these plug-ins be configured with smaller number of spaces.

Selva

-----Original Message-----
From: Hans Zeller <ha...@esgyn.com>
Sent: Thursday, June 7, 2018 9:29 AM
To: dev@trafodion.apache.org
Subject: RE: Standardize on java code style

+1 on Venkat's proposal.

The Google style seems reasonably compatible with what we have already, both in Java and in C++.

Here are a few guidelines that should help avoiding such large differences, whether we adopt the Google style or not:

- Don't format entire files, especially not if there is not a common agreed upon style
- Don't insert any tabs into source files (part of Google style)
- For those tabs that unfortunately are in the code, use 8 spaces as the width, as most simple tools (vi, github.com, emacs, Notepad, BeyondCompare, etc.) do

To Avinash's question: Yes, these are Maven projects.

Thanks,

Hans

-----Original Message-----
From: Avinash Dongre <av...@ampool.io>
Sent: Wednesday, June 6, 2018 10:38 PM
To: dev@trafodion.apache.org
Subject: Re: Standardize on java code style

I have not seen the java code, is it maven based project ??


If java project is converted into gradle, then it has spotless plugin which while building the code fixes the code style.



Thanks

Avinash


________________________________
From: Venkat Muthuswamy <ve...@esgyn.com>
Sent: 04 June 2018 23:56:21
To: dev@trafodion.apache.org
Subject: Standardize on java code style

Hi,

Given that many contributors are touching same java files and using their own editors of choice, it becomes difficult to review PRs when git reports large change when mismatch in tabs vs spaces.

Can we standardize on the java code style using the google java code style? There are plugins for eclipse and IntelliJ IDEs.
We start using these on any new files we touch going forward.

https://github.com/google/google-java-format
GitHub - google/google-java-format: Reformats Java source ...<https://github.com/google/google-java-format>
github.com
README.md google-java-format. google-java-format is a program that reformats Java source code to comply with Google Java Style.. Using the formatter from the command-line ...



https://google.github.io/styleguide/javaguide.html

For eclipse, You can download the plugin jar and copy it to your eclipse/drop-ins folder. Restart eclipse and then set your java formatter implementation to google-java-format in Window > Preferences > Java > Code Style > Formatter > Formatter Implementation

Comments ?

Venkat

Re: Standardize on java code style

Posted by Qifan Chen <qi...@esgyn.com>.
If we adopt Google style strictly, then there may be differences in naming the class data members, in a way  not compatible with our C/C++ coding conversion.  For example, we normally suffix a data member with '_', which is not the case with the Google style, available here https://google.github.io/styleguide/javaguide.html#s5.3-camel-case.  In Google style, the naming conversion for data members are as follows.


Non-constant field names (static or otherwise) are written in lowerCamelCase.


These names are typically nouns or noun phrases. For example, computedValues or index.


5.2.6 Parameter names


Parameter names are written in lowerCamelCase.


One-character parameter names in public methods should be avoided.


5.2.7 Local variable names


Local variable names are written in lowerCamelCase.


Even when final and immutable, local variables are not considered to be constants, and should not be styled as constants.



In addition, the # of white space characters to indent a new block of code or a switch statement is 2, and tabs should not be used to indent blocks etc.


Sounds like we may need to either follow the Google style completely, or follow it in principle but allow a slight deviation from it, such as suffix data members  with '_'.  I personally do not use tabs for indentation and put 3 white characters before the start of a new block.


Thanks --Qifan

________________________________
From: Selva Govindarajan <se...@esgyn.com>
Sent: Thursday, June 7, 2018 11:53:19 AM
To: dev@trafodion.apache.org
Subject: RE: Standardize on java code style

Are there any other guidelines for contributors who use neither of these IDE or any IDE at all?  In my opinion, 8 spaces seem to be a large indentation that would take the code away from the screen.  Can these plug-ins be configured with smaller number of spaces.

Selva

-----Original Message-----
From: Hans Zeller <ha...@esgyn.com>
Sent: Thursday, June 7, 2018 9:29 AM
To: dev@trafodion.apache.org
Subject: RE: Standardize on java code style

+1 on Venkat's proposal.

The Google style seems reasonably compatible with what we have already, both in Java and in C++.

Here are a few guidelines that should help avoiding such large differences, whether we adopt the Google style or not:

- Don't format entire files, especially not if there is not a common agreed upon style
- Don't insert any tabs into source files (part of Google style)
- For those tabs that unfortunately are in the code, use 8 spaces as the width, as most simple tools (vi, github.com, emacs, Notepad, BeyondCompare, etc.) do

To Avinash's question: Yes, these are Maven projects.

Thanks,

Hans

-----Original Message-----
From: Avinash Dongre <av...@ampool.io>
Sent: Wednesday, June 6, 2018 10:38 PM
To: dev@trafodion.apache.org
Subject: Re: Standardize on java code style

I have not seen the java code, is it maven based project ??


If java project is converted into gradle, then it has spotless plugin which while building the code fixes the code style.



Thanks

Avinash


________________________________
From: Venkat Muthuswamy <ve...@esgyn.com>
Sent: 04 June 2018 23:56:21
To: dev@trafodion.apache.org
Subject: Standardize on java code style

Hi,

Given that many contributors are touching same java files and using their own editors of choice, it becomes difficult to review PRs when git reports large change when mismatch in tabs vs spaces.

Can we standardize on the java code style using the google java code style? There are plugins for eclipse and IntelliJ IDEs.
We start using these on any new files we touch going forward.

https://github.com/google/google-java-format
GitHub - google/google-java-format: Reformats Java source ...<https://github.com/google/google-java-format>
github.com
README.md google-java-format. google-java-format is a program that reformats Java source code to comply with Google Java Style.. Using the formatter from the command-line ...



https://google.github.io/styleguide/javaguide.html

For eclipse, You can download the plugin jar and copy it to your eclipse/drop-ins folder. Restart eclipse and then set your java formatter implementation to google-java-format in Window > Preferences > Java > Code Style > Formatter > Formatter Implementation

Comments ?

Venkat

RE: Standardize on java code style

Posted by Selva Govindarajan <se...@esgyn.com>.
Are there any other guidelines for contributors who use neither of these IDE or any IDE at all?  In my opinion, 8 spaces seem to be a large indentation that would take the code away from the screen.  Can these plug-ins be configured with smaller number of spaces.

Selva

-----Original Message-----
From: Hans Zeller <ha...@esgyn.com> 
Sent: Thursday, June 7, 2018 9:29 AM
To: dev@trafodion.apache.org
Subject: RE: Standardize on java code style

+1 on Venkat's proposal.

The Google style seems reasonably compatible with what we have already, both in Java and in C++.

Here are a few guidelines that should help avoiding such large differences, whether we adopt the Google style or not:

- Don't format entire files, especially not if there is not a common agreed upon style
- Don't insert any tabs into source files (part of Google style)
- For those tabs that unfortunately are in the code, use 8 spaces as the width, as most simple tools (vi, github.com, emacs, Notepad, BeyondCompare, etc.) do

To Avinash's question: Yes, these are Maven projects.

Thanks,

Hans

-----Original Message-----
From: Avinash Dongre <av...@ampool.io> 
Sent: Wednesday, June 6, 2018 10:38 PM
To: dev@trafodion.apache.org
Subject: Re: Standardize on java code style

I have not seen the java code, is it maven based project ??


If java project is converted into gradle, then it has spotless plugin which while building the code fixes the code style.



Thanks

Avinash


________________________________
From: Venkat Muthuswamy <ve...@esgyn.com>
Sent: 04 June 2018 23:56:21
To: dev@trafodion.apache.org
Subject: Standardize on java code style

Hi,

Given that many contributors are touching same java files and using their own editors of choice, it becomes difficult to review PRs when git reports large change when mismatch in tabs vs spaces.

Can we standardize on the java code style using the google java code style? There are plugins for eclipse and IntelliJ IDEs.
We start using these on any new files we touch going forward.

https://github.com/google/google-java-format
GitHub - google/google-java-format: Reformats Java source ...<https://github.com/google/google-java-format>
github.com
README.md google-java-format. google-java-format is a program that reformats Java source code to comply with Google Java Style.. Using the formatter from the command-line ...



https://google.github.io/styleguide/javaguide.html

For eclipse, You can download the plugin jar and copy it to your eclipse/drop-ins folder. Restart eclipse and then set your java formatter implementation to google-java-format in Window > Preferences > Java > Code Style > Formatter > Formatter Implementation

Comments ?

Venkat

RE: Standardize on java code style

Posted by Hans Zeller <ha...@esgyn.com>.
+1 on Venkat's proposal.

The Google style seems reasonably compatible with what we have already, both in Java and in C++.

Here are a few guidelines that should help avoiding such large differences, whether we adopt the Google style or not:

- Don't format entire files, especially not if there is not a common agreed upon style
- Don't insert any tabs into source files (part of Google style)
- For those tabs that unfortunately are in the code, use 8 spaces as the width, as most simple tools (vi, github.com, emacs, Notepad, BeyondCompare, etc.) do

To Avinash's question: Yes, these are Maven projects.

Thanks,

Hans

-----Original Message-----
From: Avinash Dongre <av...@ampool.io> 
Sent: Wednesday, June 6, 2018 10:38 PM
To: dev@trafodion.apache.org
Subject: Re: Standardize on java code style

I have not seen the java code, is it maven based project ??


If java project is converted into gradle, then it has spotless plugin which while building the code fixes the code style.



Thanks

Avinash


________________________________
From: Venkat Muthuswamy <ve...@esgyn.com>
Sent: 04 June 2018 23:56:21
To: dev@trafodion.apache.org
Subject: Standardize on java code style

Hi,

Given that many contributors are touching same java files and using their own editors of choice, it becomes difficult to review PRs when git reports large change when mismatch in tabs vs spaces.

Can we standardize on the java code style using the google java code style? There are plugins for eclipse and IntelliJ IDEs.
We start using these on any new files we touch going forward.

https://github.com/google/google-java-format
GitHub - google/google-java-format: Reformats Java source ...<https://github.com/google/google-java-format>
github.com
README.md google-java-format. google-java-format is a program that reformats Java source code to comply with Google Java Style.. Using the formatter from the command-line ...



https://google.github.io/styleguide/javaguide.html

For eclipse, You can download the plugin jar and copy it to your eclipse/drop-ins folder. Restart eclipse and then set your java formatter implementation to google-java-format in Window > Preferences > Java > Code Style > Formatter > Formatter Implementation

Comments ?

Venkat

Re: Standardize on java code style

Posted by Avinash Dongre <av...@ampool.io>.
I have not seen the java code, is it maven based project ??


If java project is converted into gradle, then it has spotless plugin which while building the code fixes the code style.



Thanks

Avinash


________________________________
From: Venkat Muthuswamy <ve...@esgyn.com>
Sent: 04 June 2018 23:56:21
To: dev@trafodion.apache.org
Subject: Standardize on java code style

Hi,

Given that many contributors are touching same java files and using their own editors of choice, it becomes difficult to review PRs when git reports large change when mismatch in tabs vs spaces.

Can we standardize on the java code style using the google java code style? There are plugins for eclipse and IntelliJ IDEs.
We start using these on any new files we touch going forward.

https://github.com/google/google-java-format
GitHub - google/google-java-format: Reformats Java source ...<https://github.com/google/google-java-format>
github.com
README.md google-java-format. google-java-format is a program that reformats Java source code to comply with Google Java Style.. Using the formatter from the command-line ...



https://google.github.io/styleguide/javaguide.html

For eclipse, You can download the plugin jar and copy it to your eclipse/drop-ins folder. Restart eclipse and then set your java formatter implementation to google-java-format in Window > Preferences > Java > Code Style > Formatter > Formatter Implementation

Comments ?

Venkat