RFR: 8091673: Public focus traversal API for use in custom controls [v4]

Kevin Rushforth kcr at openjdk.org
Tue Oct 29 16:03:17 UTC 2024


On Tue, 29 Oct 2024 15:28:39 GMT, Andy Goryachev <angorya at openjdk.org> wrote:

>> I agree that especially when each switch case is on a single line, indenting is the most sensible thing to do. It's a little more defensible to treat the standard switch `case NNNN:`, on a line by itself, as a label which is placed at the same indentation level as the switch itself (but even indenting it is more consistent).
>> 
>> Taking this example:
>> 
>> Option 1 - don't indent:
>> 
>> 
>>         String s = switch(val) {
>>         case 1 -> "one";
>>         case 2 -> "two";
>>         // ...
>>         default -> "unknown";
>>         };
>> 
>> Option 2 - indent:
>> 
>> 
>>         String s = switch(val) {
>>             case 1 -> "one";
>>             case 2 -> "two";
>>             // ...
>>             default -> "unknown";
>>         };
>> 
>> 
>> It seems pretty clear that the second option is easier to read. Virtually _all_ such uses in the JDK, and all uses up to now in JavaFX use the second pattern.
>> 
>> @andy-goryachev-oracle care to  make a counter-argument?
>
> Sure:
> 
> 
> String s = switch(val) {
> case 1 ->
>     "one";
> case 2 ->
>     "two";
> default ->
>     "unknown";
> };

That isn't an example of "everything on one line". That's effectively the "switch case NNNN:, on a line by itself", which is defensible, although still not preferred.

Anyway, what you currently have is what I called option 1, and it doesn't seem very readable. I'll still leave it up to you, but please consider the comments made in this thread.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1604#discussion_r1821123866


More information about the openjfx-dev mailing list