Indenting code?
Jim Gish
jim.gish at oracle.com
Fri Sep 14 17:23:32 UTC 2012
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
discuss at 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.gish at oracle.com
More information about the discuss
mailing list