Re: Indenting code?
Paul, On 2012-09-17 17:52, Paul Sandoz wrote: > The solution to that is to re-format all JDK source code using a tool > and commit independent of any fixes, i bet the NBs formatter could be > extracted for command line operation. Netbeans formatter is OK to do simple job why editing, but it couldn't be used as a standalone tool. There are plenty of separate tools, so someone have to invest time to evaluate some of these tools, choose one and write config that mimic netbeans settings. > FWIW i really don't care about what the style would be as long as it > is not equivalent to a Huggy Bear sofa so garish as to require one to > wear peril sensitive sunglasses. Personally, I also don't think that the coding style is important. It's important to have the style common one over all code - which one doesn't really matter. -Dmitry -- Dmitry Samersoff Java Hotspot development team, SPB04 * There will come soft rains ...
Re: Indenting code?
On Sep 14, 2012, at 1:20 PM, Alan Bateman wrote: > On 14/09/2012 01:21, Brad Wetmore wrote: >> Netbean's automatic formatting does a pretty good job with new code. >> However, I think the general advice is to not change existing code just >> because. When you're dealing with multiple release families, it makes the >> merges much more difficult. >> >> Brad > One think that Paul Sandoz suggested recently is that we should have a NB > template that folks can use to avoid some discussions/debates on styles. +1 i.e. make producing and reviewing code easier. > It would be great for someone to run with that, the hard part is of course > that it will be impossible to get agreement. Personally I find NB's defaults > okay but there are several cases where its indenting is horrible. > > Anyway, the main advice I think is to keep things locally consistent where > possible. Also major refactoring or formatting in a bug fix is a royal pain > for reviewers. > The solution to that is to re-format all JDK source code using a tool and commit independent of any fixes, i bet the NBs formatter could be extracted for command line operation. IMHO it requires a benevolent dictator to decide on the exact formatting rules, since agreement is unlikely to be reached and much more heat than light will ever come from such discussions about where to place a '{'. FWIW i really don't care about what the style would be as long as it is not equivalent to a Huggy Bear sofa so garish as to require one to wear peril sensitive sunglasses. Paul.
Re: Indenting code?
Jim, IMHO, It's really boring task to format big peace of code manually. The worst scenario I could imagine - autoformat code by netbeans and then manually adjust it to some coding standard. Is it possible to: 1. Rich some common point between netbeans and old sun coding standard. 2. Provide a config for one of available opensource beautifiers (jalopy, uncrustify etc.) for people who don't use netbeans. 3. Write results as coding standard. -Dmitry On 2012-09-14 21:23, Jim Gish wrote: > While it is true that NB and Eclipse and other IDEs offer auto > formatting and that will suit some us, I also no that there are some > amongst us who still use emacs and vi and possibly other non-IDE > editors. The first thing to agree on is what standard are we coding > to. I had assumed it was the old Sun Java coding standards ( > http://www.oracle.com/technetwork/java/codeconv-138413.html) > > Is that the case? > > If not, I suggest that we /don't /open this up to a full-fledged > discussion of what the standard should be. I've been involved in far > too many such religious debates over the years that end up reminding me > of the famous Belushi-esque food fight scene from Animal House. > Instead, if any question on any one individual point comes up, we look > at the predominate approach in the existing code and use that. > > As Alan points out, local consistency is important to maintain. In the > unlikely event that an entire piece of code is rewritten, then it's ok > to bring it up to the current standard, otherwise don't mess with it. > In other words, there are more important things to consider than whether > any one piece of code meets the standard. Although that would be ideal, > we do have to consider the consequences of major formatting changes, > since those will impact the ease of interpreting diffs, and far more > significant, ability to manage merging. > > If we agree that the old Sun Java coding standards are what we /are > mostly/ using, then we can identify formatting templates for the major > IDEs, and other tools as needed. > > Jim > > Also, this is broader than net-dev, so I'm moving the discussion to > disc...@openjdk.java.net. Please respond there. > On 09/14/2012 12:27 PM, Chris Hegarty wrote: >> On 14/09/12 12:20, Alan Bateman wrote: >>> On 14/09/2012 01:21, Brad Wetmore wrote: Netbean's automatic formatting does a pretty good job with new code. However, I think the general advice is to not change existing code just because. When you're dealing with multiple release families, it makes the merges much more difficult. Brad >>> One think that Paul Sandoz suggested recently is that we should have a >>> NB template that folks can use to avoid some discussions/debates on >>> styles. It would be great for someone to run with that, the hard part is >>> of course that it will be impossible to get agreement. Personally I find >>> NB's defaults okay but there are several cases where its indenting is >>> horrible. >> >> I did play with NB somewhat trying to get it follow, exactly, the >> preferred style in some areas of the JDK code. I was able to get it >> close, or at least better than the default, but I don't believe it is >> possible to get it to do exactly what we want. >> >> -Chris. >> >>> Anyway, the main advice I think is to keep things locally consistent >>> where possible. Also major refactoring or formatting in a bug fix is a >>> royal pain for reviewers. >>> >>> -Alan > > -- > Jim Gish | Consulting Member of Technical Staff | +1.781.442.0304 > Oracle Java Platform Group | Core Libraries Team > 35 Network Drive > Burlington, MA 01803 > jim.g...@oracle.com > -- Dmitry Samersoff Java Hotspot development team, SPB04 * There will come soft rains ...
Re: Indenting code?
While it is true that NB and Eclipse and other IDEs offer auto formatting and that will suit some us, I also no that there are some amongst us who still use emacs and vi and possibly other non-IDE editors. The first thing to agree on is what standard are we coding to. I had assumed it was the old Sun Java coding standards ( http://www.oracle.com/technetwork/java/codeconv-138413.html) Is that the case? If not, I suggest that we /don't /open this up to a full-fledged discussion of what the standard should be. I've been involved in far too many such religious debates over the years that end up reminding me of the famous Belushi-esque food fight scene from Animal House. Instead, if any question on any one individual point comes up, we look at the predominate approach in the existing code and use that. As Alan points out, local consistency is important to maintain. In the unlikely event that an entire piece of code is rewritten, then it's ok to bring it up to the current standard, otherwise don't mess with it. In other words, there are more important things to consider than whether any one piece of code meets the standard. Although that would be ideal, we do have to consider the consequences of major formatting changes, since those will impact the ease of interpreting diffs, and far more significant, ability to manage merging. If we agree that the old Sun Java coding standards are what we /are mostly/ using, then we can identify formatting templates for the major IDEs, and other tools as needed. Jim Also, this is broader than net-dev, so I'm moving the discussion to disc...@openjdk.java.net. Please respond there. On 09/14/2012 12:27 PM, Chris Hegarty wrote: On 14/09/12 12:20, Alan Bateman wrote: On 14/09/2012 01:21, Brad Wetmore wrote: Netbean's automatic formatting does a pretty good job with new code. However, I think the general advice is to not change existing code just because. When you're dealing with multiple release families, it makes the merges much more difficult. Brad One think that Paul Sandoz suggested recently is that we should have a NB template that folks can use to avoid some discussions/debates on styles. It would be great for someone to run with that, the hard part is of course that it will be impossible to get agreement. Personally I find NB's defaults okay but there are several cases where its indenting is horrible. I did play with NB somewhat trying to get it follow, exactly, the preferred style in some areas of the JDK code. I was able to get it close, or at least better than the default, but I don't believe it is possible to get it to do exactly what we want. -Chris. Anyway, the main advice I think is to keep things locally consistent where possible. Also major refactoring or formatting in a bug fix is a royal pain for reviewers. -Alan -- Jim Gish | Consulting Member of Technical Staff | +1.781.442.0304 Oracle Java Platform Group | Core Libraries Team 35 Network Drive Burlington, MA 01803 jim.g...@oracle.com
Re: Indenting code?
On Sep 14 2012, at 09:27 , Chris Hegarty wrote: > On 14/09/12 12:20, Alan Bateman wrote: >> On 14/09/2012 01:21, Brad Wetmore wrote: >>> Netbean's automatic formatting does a pretty good job with new code. >>> However, I think the general advice is to not change existing code >>> just because. When you're dealing with multiple release families, it >>> makes the merges much more difficult. >>> >>> Brad >> One think that Paul Sandoz suggested recently is that we should have a >> NB template that folks can use to avoid some discussions/debates on >> styles. It would be great for someone to run with that, the hard part is >> of course that it will be impossible to get agreement. Personally I find >> NB's defaults okay but there are several cases where its indenting is >> horrible. > > I did play with NB somewhat trying to get it follow, exactly, the preferred > style in some areas of the JDK code. I was able to get it close, or at least > better than the default, but I don't believe it is possible to get it to do > exactly what we want. Please report issues with the NB formatter not following "Code Conventions for the Java Programming Language" on this issue: http://netbeans.org/bugzilla/show_bug.cgi?id=124169
Re: Indenting code?
On 14/09/12 12:20, Alan Bateman wrote: On 14/09/2012 01:21, Brad Wetmore wrote: Netbean's automatic formatting does a pretty good job with new code. However, I think the general advice is to not change existing code just because. When you're dealing with multiple release families, it makes the merges much more difficult. Brad One think that Paul Sandoz suggested recently is that we should have a NB template that folks can use to avoid some discussions/debates on styles. It would be great for someone to run with that, the hard part is of course that it will be impossible to get agreement. Personally I find NB's defaults okay but there are several cases where its indenting is horrible. I did play with NB somewhat trying to get it follow, exactly, the preferred style in some areas of the JDK code. I was able to get it close, or at least better than the default, but I don't believe it is possible to get it to do exactly what we want. -Chris. Anyway, the main advice I think is to keep things locally consistent where possible. Also major refactoring or formatting in a bug fix is a royal pain for reviewers. -Alan
Re: Indenting code?
One useful feature in Netbeans is that you can select a block of code and just (re)format that. So, there's no need to worry about affecting the rest of the file you are editing. - Michael On 14/09/12 01:59, Weijun Wang wrote: On 09/14/2012 08:21 AM, Brad Wetmore wrote: Netbean's automatic formatting does a pretty good job with new code. That's Alt-Shift-F, which I rarely dare to press, because it change existing codes. In fact, NetBeans is doing very smart indentation while you are coding, at least it adheres to the Sun/Oracle convention. The only thing I need to care about is breaking long lines. I also turn on Options|Editor|General|Remove Trailing Whitespace From Modified Lines Only. However, I think the general advice is to not change existing code just because. When you're dealing with multiple release families, it makes the merges much more difficult. Yes, yes, yes, and it makes code reviewers wondering what really changed. -Max Brad On 9/13/2012 6:18 AM, John Zavgren wrote: Greetings: I have a simple question about how to enforce code styles for: java, c, and c++. I know there are style guides that legislate the indentation, "curly brace and parenthesis management", etc. I'm looking for a simple automatic way to transform any source code file so that it's image is guaranteed to be "correct". No thinking required. What I normally do is use an open source tool named "indent", e.g., indent -bap -bbb -bl -nce -l80 file1.cpp file2.h file3.c file4.java And, I put an "indent" target in my make files. Consequently whenever I make something, the very first step is to format the code, and I know that when I do a check in later on... I never have to think about whether or not the code conforms to a style guide... because the options I gave to "indent" implemented this guide. (You can do similar things with emacs too.) Any ideas? Thanks! John Zavgren john.zavg...@oracle.com
Re: Indenting code?
On 14/09/2012 01:21, Brad Wetmore wrote: Netbean's automatic formatting does a pretty good job with new code. However, I think the general advice is to not change existing code just because. When you're dealing with multiple release families, it makes the merges much more difficult. Brad One think that Paul Sandoz suggested recently is that we should have a NB template that folks can use to avoid some discussions/debates on styles. It would be great for someone to run with that, the hard part is of course that it will be impossible to get agreement. Personally I find NB's defaults okay but there are several cases where its indenting is horrible. Anyway, the main advice I think is to keep things locally consistent where possible. Also major refactoring or formatting in a bug fix is a royal pain for reviewers. -Alan
Re: Indenting code?
On 09/14/2012 08:21 AM, Brad Wetmore wrote: Netbean's automatic formatting does a pretty good job with new code. That's Alt-Shift-F, which I rarely dare to press, because it change existing codes. In fact, NetBeans is doing very smart indentation while you are coding, at least it adheres to the Sun/Oracle convention. The only thing I need to care about is breaking long lines. I also turn on Options|Editor|General|Remove Trailing Whitespace From Modified Lines Only. However, I think the general advice is to not change existing code just because. When you're dealing with multiple release families, it makes the merges much more difficult. Yes, yes, yes, and it makes code reviewers wondering what really changed. -Max Brad On 9/13/2012 6:18 AM, John Zavgren wrote: Greetings: I have a simple question about how to enforce code styles for: java, c, and c++. I know there are style guides that legislate the indentation, "curly brace and parenthesis management", etc. I'm looking for a simple automatic way to transform any source code file so that it's image is guaranteed to be "correct". No thinking required. What I normally do is use an open source tool named "indent", e.g., indent -bap -bbb -bl -nce -l80 file1.cpp file2.h file3.c file4.java And, I put an "indent" target in my make files. Consequently whenever I make something, the very first step is to format the code, and I know that when I do a check in later on... I never have to think about whether or not the code conforms to a style guide... because the options I gave to "indent" implemented this guide. (You can do similar things with emacs too.) Any ideas? Thanks! John Zavgren john.zavg...@oracle.com
Re: Indenting code?
Netbean's automatic formatting does a pretty good job with new code. However, I think the general advice is to not change existing code just because. When you're dealing with multiple release families, it makes the merges much more difficult. Brad On 9/13/2012 6:18 AM, John Zavgren wrote: Greetings: I have a simple question about how to enforce code styles for: java, c, and c++. I know there are style guides that legislate the indentation, "curly brace and parenthesis management", etc. I'm looking for a simple automatic way to transform any source code file so that it's image is guaranteed to be "correct". No thinking required. What I normally do is use an open source tool named "indent", e.g., indent -bap -bbb -bl -nce -l80 file1.cpp file2.h file3.c file4.java And, I put an "indent" target in my make files. Consequently whenever I make something, the very first step is to format the code, and I know that when I do a check in later on... I never have to think about whether or not the code conforms to a style guide... because the options I gave to "indent" implemented this guide. (You can do similar things with emacs too.) Any ideas? Thanks! John Zavgren john.zavg...@oracle.com
Indenting code?
Greetings: I have a simple question about how to enforce code styles for: java, c, and c++. I know there are style guides that legislate the indentation, "curly brace and parenthesis management", etc. I'm looking for a simple automatic way to transform any source code file so that it's image is guaranteed to be "correct". No thinking required. What I normally do is use an open source tool named "indent", e.g., indent -bap -bbb -bl -nce -l80 file1.cpp file2.h file3.c file4.java And, I put an "indent" target in my make files. Consequently whenever I make something, the very first step is to format the code, and I know that when I do a check in later on... I never have to think about whether or not the code conforms to a style guide... because the options I gave to "indent" implemented this guide. (You can do similar things with emacs too.) Any ideas? Thanks! John Zavgren john.zavg...@oracle.com