RFR: Updated section on Code Conventions.

Joe Darcy joe.darcy at oracle.com
Sat Jun 27 01:37:44 UTC 2020


On 6/26/2020 10:54 AM, Brian Goetz wrote:
> While this is not a direct answer to your question, I do have a secondary interest in the existence of a “style guide”, whether or not it is considered mandatory for OpenJDK code.
>
> Why did Andreas undertake the (almost certainly thankless) task of updating the style guide in the first place?  Because it was “out of date”.  What does that mean?  I think two main things:
>
>      - There were some overly fussy guidelines that came from the very early days (“sort field names by Levenstein distance from 'foo’”) that the passage of time had revealed to be a silly waste of effort;
>      - The language had evolved significantly since the guidelines were written, and so there were many language features that were not covered by the style guidelines.
>
> As the stewards of the Java language, we have an opportunity to get Java developers off on the right foot using new language features — if we provide reasonable style and usage information for them.  Having good initial advice will reduce the time it takes to equilibrate on usage patterns, as well as eliminating gratuitously multimodal distributions of usages.  But, the window for doing so is small before everyone chooses their own style for indenting, say, enum constant lists.
>
> To the extent that it forms a “from the source” set of recommendations for new language features (which are coming fast and furious these days!), a non-authoritative guide still has significant value.
>

As a concrete example, such a style guide would provide a natural and 
more discoverable home for useful documents like Stuart's

     "Local Variable Type Inference: Style Guidelines"
     https://openjdk.java.net/projects/amber/LVTIstyle.html

-Joe



More information about the jdk-dev mailing list