On Fri, 9 Oct 2026 03:54:04 GMT, John Hendrikx <[email protected]> wrote:

>> we should be using consistent formatting.  having individual styles makes it 
>> more difficult to read the code.  I don't like Egyptian braces, but I would 
>> not introduce them here even when they are clearly counterproductive
>> 
>> 
>> public class Foo { // you really want to insert an empty line here, right?
>>    private Something something;
>>    private SomethingElse somethingElse;
>> 
>>    public Foo() { }
>> }
>
> I'm not sure what you're saying here Andy, I would never insert an empty line 
> in that location, just like I never do that for any other block (ie. more 
> consistent than only doing it for classes). 
> 
> I think the way I format things is more consistent than most:
> - No empty line after any block opener (ie. `if` treated the same as `class` 
> blocks)
> - No placing keywords after a block closer (ie. `else` on next line, just 
> like `case`)
> - A block always requires a new indent level (so `case` is not aligned with 
> `switch`)
> - Empty blocks can be collapsed to `{}` (nice for records, empty classes, 
> methods or loop statements)
> - All closing parentheses are placed in the same way, no exceptions for 
> blocks, function or array parentheses:
> 
> someFunction(
>     a, b
> );  // here and not on the previous line, just like blocks
> 
> - A line with multiple unclosed opening parenthesis, will always be matched 
> with another line that has the exact same amount of closing parenthesis
> - An empty line between any declaration line and non-declaration line
> - Strict rectangle rule (the ability to draw a rectangle around any code 
> block, and not having any code from a higher nesting level get captured by 
> it, applied to blocks, functions and array parenthesis alike)
> - No double indents for continuations, it's clear without wasting another 
> indent
> 
> Anyway, if there is a coding style somewhere, then feel free to point it out. 
> From my experience across the JavaFX (and JDK code base) there isn't one 
> style to rule them all so I tend to adhere to the surrounding style (as 
> sometimes even in one file styles significantly differ) -- if it is a new 
> file, one can use their own consistent style; I generally for my own teams 
> steer (with concensus) towards a compromise that code is "readable" without 
> enforcing some specific style, this leaves room for some individual choices 
> which tends to make everyone happy; the list of rules is therefore short (use 
> 4 space indents, break off long lines, always use blocks, one statement per 
> line and, most importantly, be *consistent* with whatever rules you use). The 
> only other solution is to have strict rigid formatting enforced by the build, 
> making everyone equally unhappy when their code is the one being butchered.
> 
> So far I thought FX leaned towards a lenient style, as long as it is 
> readable, and not being too nitpicky about tiny individual style choices.

we use OpenJDK standard:
https://www.oracle.com/java/technologies/javase/codeconventions-statements.html#449

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/1081#discussion_r4231098075

Reply via email to