>
> My only problem with a more assertive “moveFocus” is that it implies a
> success


True, but the JDK already uses it everywhere. Mutation methods on
collections are all named as definitive actions even if they don't succeed.
In general, setters might also fail (usually in the case of NPE), but they
are named `setXxx`.
I would say it depends on what failure looks like. If you throw an
exception, then this name is fine because you're going to be told it
failed. If you return a boolean to indicate success (a design I don't like,
but collections do it), it might also be fine. However, if you "fail
silently", it could be a problem.
In my code, I do sometimes use the `try` prefix: `tryToFocus` in this case.
Then again, I prefer prose over convention so my method names can be
rather... descriptive. The advantage I find with writing descriptive names
is that they get clunky if the method does too much, which prompts me to
split the method, resulting in what I would call cleaner code. Not everyone
agrees on this.
Another way to name a method is to use the argument name as part of its
name. E.g., instead of `moveFocus(Node node)`, you would write
`moveFocusTo(Node node)`. Here, the argument is a glorified direction, so
it partially works: `moveFocusTo(TraversalDirection.NEXT)` works well,
`moveFocusTo(TraversalDirection.UP)` is OK.

On Wed, Oct 23, 2024 at 9:15 PM Kevin Rushforth <kevin.rushfo...@oracle.com>
wrote:

> I think we just need a good name. I agree that "predict" isn't the API we
> want.
>
> How about "requestFocusTraversal"? It has symmetry with requestFocus.
>
> -- Kevin
>
>
> On 10/23/2024 11:05 AM, Andy Goryachev wrote:
>
> I don't think prediction should be the functionality we want in the Node.
> This functionality, in my opinion, belongs to the traversal policy.
>
>
>
> All we want is to navigate away from the specified node.
>
>
>
> It might have been easier had we kept the original FocusTraversal class -
> not only one can add a bunch of convenience methods (predict, infer,
> contemplate, etc.) but we could have added applicationFocusOwnerProperty()
> etc.
>
>
>
> Do we need another brainstorming round?
>
>
>
> -andy
>
>
>
>
>
>
>
>
>
> *From: *openjfx-dev <openjfx-dev-r...@openjdk.org>
> <openjfx-dev-r...@openjdk.org> on behalf of Michael Strauß
> <michaelstr...@gmail.com> <michaelstr...@gmail.com>
> *Date: *Wednesday, October 23, 2024 at 10:58
> *To: *
> *Cc: *openjfx-dev@openjdk.org <openjfx-dev@openjdk.org>
> <openjfx-dev@openjdk.org>
> *Subject: *Re: Proposal: Focus Traversal API
>
> How about „predictFocus“, which will return a Node without changing focus?
>
>
>
> This would give applications even more flexibility, because they can then
> decide if they want to go ahead and actually change focus by calling
> predictFocus()?.requestFocus()
>
>
>
>
>
> Andy Goryachev <andy.goryac...@oracle.com> schrieb am Mi. 23. Okt. 2024
> um 19:16:
>
> Thank you for suggestion!
>
>
>
> My only problem with a more assertive “moveFocus” is that it implies a
> success, while this API may or may not succeed (similarly to requestFocus).
>
>
>
> The word "shift" in "shiftFocus" might clash with the "shift" key, don't
> really like that.
>
>
>
> Maybe "requestTraversal" although it will expand auto-completion list that
> has 2 items already.  Welcome any alternative, as long as it's not creat().
>
>
>
> -andy
>
>
>
>
>
> *From: *openjfx-dev <openjfx-dev-r...@openjdk.org> on behalf of Michael
> Strauß <michaelstr...@gmail.com>
> *Date: *Wednesday, October 23, 2024 at 10:05
> *To: *
> *Cc: *openjfx-dev@openjdk.org <openjfx-dev@openjdk.org>
> *Subject: *Re: Proposal: Focus Traversal API
>
> Maybe we can polish the naming a bit:
>
> When used as a transitive verb, "traverse" means (according to
> Merriam-Webster): to go or travel across or over, to move or pass
> along or through.
>
> MW gives the example: "light rays traversing a crystal". So one thing
> is moving (light rays), while the other thing is static (a crystal).
> Cambridge gives the example "Stanley traversed the continent from west
> to east." Again, "Stanley" is moving, "the continent" is static.
>
> Since "traverseFocus" is a transitive verb followed by a direct noun,
> it sounds to me like "focus" is the thing that can be traversed over
> or across.
> As an analogy, let's call the method "traverseContinent" for a moment.
> It becomes obvious that "continent" is the space which is traveled
> across, and not the thing travelling.
>
> In our case, "focus" is the moving thing, not the thing that it is
> moved across. I would use something like "moveFocus", "shiftFocus", or
> something along those lines.
>
> As for "TraversalDirection", I think it is acceptable, but I'll note
> that to me, "direction" implies one of the four directional modes, not
> the two logical modes (previous and next).
>
>
>

Reply via email to