<div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span style="font-family:"Iosevka Fixed SS16";font-size:14.6667px">My only problem with a more assertive “moveFocus” is that it implies a success</span></blockquote><div><br></div><div>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`.</div><div>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.</div><div>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.</div><div>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.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Oct 23, 2024 at 9:15 PM Kevin Rushforth <<a href="mailto:kevin.rushforth@oracle.com">kevin.rushforth@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>

  
  <div>
    I think we just need a good name. I agree that "predict" isn't the
    API we want.<br>
    <br>
    How about "requestFocusTraversal"? It has symmetry with
    requestFocus.<br>
    <br>
    -- Kevin<br>
    <br>
    <br>
    <div>On 10/23/2024 11:05 AM, Andy Goryachev
      wrote:<br>
    </div>
    <blockquote type="cite">
      
      
      
      <div>
        <p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16"">I
            don't think prediction should be the functionality we want
            in the Node.  This functionality, in my opinion, belongs to
            the traversal policy.<u></u><u></u></span></p>
        <p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16""><u></u> <u></u></span></p>
        <p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16"">All
            we want is to navigate away from the specified node.<u></u><u></u></span></p>
        <p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16""><u></u> <u></u></span></p>
        <p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16"">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.<u></u><u></u></span></p>
        <p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16""><u></u> <u></u></span></p>
        <p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16"">Do
            we need another brainstorming round?<u></u><u></u></span></p>
        <p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16""><u></u> <u></u></span></p>
        <p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16"">-andy<u></u><u></u></span></p>
        <p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16""><u></u> <u></u></span></p>
        <p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16""><u></u> <u></u></span></p>
        <p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16""><u></u> <u></u></span></p>
        <p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16""><u></u> <u></u></span></p>
        <div id="m_3993873281129632795mail-editor-reference-message-container">
          <div>
            <div>
              <div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(181,196,223);padding:3pt 0in 0in">
                <p class="MsoNormal" style="margin-bottom:12pt"><b><span style="font-size:12pt;color:black">From:
                    </span></b><span style="font-size:12pt;color:black">openjfx-dev
                    <a href="mailto:openjfx-dev-retn@openjdk.org" target="_blank"><openjfx-dev-retn@openjdk.org></a> on behalf of
                    Michael Strauß <a href="mailto:michaelstrau2@gmail.com" target="_blank"><michaelstrau2@gmail.com></a><br>
                    <b>Date: </b>Wednesday, October 23, 2024 at 10:58<br>
                    <b>To: </b><br>
                    <b>Cc: </b><a href="mailto:openjfx-dev@openjdk.org" target="_blank">openjfx-dev@openjdk.org</a>
                    <a href="mailto:openjfx-dev@openjdk.org" target="_blank"><openjfx-dev@openjdk.org></a><br>
                    <b>Subject: </b>Re: Proposal: Focus Traversal API<u></u><u></u></span></p>
              </div>
              <div>
                <p class="MsoNormal"><span style="font-size:12pt">How
                    about „predictFocus“, which will return a Node
                    without changing focus?<u></u><u></u></span></p>
              </div>
              <div>
                <p class="MsoNormal"><span style="font-size:12pt"><u></u> <u></u></span></p>
              </div>
              <div>
                <p class="MsoNormal"><span style="font-size:12pt">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()<u></u><u></u></span></p>
              </div>
              <div>
                <p class="MsoNormal"><span style="font-size:12pt"><u></u> <u></u></span></p>
              </div>
              <div>
                <p class="MsoNormal"><span style="font-size:12pt"><u></u> <u></u></span></p>
                <div>
                  <div>
                    <p class="MsoNormal"><span style="font-size:12pt">Andy
                        Goryachev <<a href="mailto:andy.goryachev@oracle.com" target="_blank">andy.goryachev@oracle.com</a>>
                        schrieb am Mi. 23. Okt. 2024 um 19:16:<u></u><u></u></span></p>
                  </div>
                  <blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in">
                    <div>
                      <div>
                        <p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16"">Thank
                            you for suggestion!</span><span style="font-size:12pt"><u></u><u></u></span></p>
                        <p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16""> </span><span style="font-size:12pt"><u></u><u></u></span></p>
                        <p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16"">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).</span><span style="font-size:12pt"><u></u><u></u></span></p>
                        <p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16""> </span><span style="font-size:12pt"><u></u><u></u></span></p>
                        <p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16"">The
                            word "shift" in "shiftFocus" might clash
                            with the "shift" key, don't really like
                            that.</span><span style="font-size:12pt"><u></u><u></u></span></p>
                        <p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16""> </span><span style="font-size:12pt"><u></u><u></u></span></p>
                        <p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16"">Maybe
                            "requestTraversal" although it will expand
                            auto-completion list that has 2 items
                            already.  Welcome any alternative, as long
                            as it's not creat().</span><span style="font-size:12pt"><u></u><u></u></span></p>
                      </div>
                    </div>
                    <div>
                      <div>
                        <p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16""> </span><span style="font-size:12pt"><u></u><u></u></span></p>
                        <p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16"">-andy</span><span style="font-size:12pt"><u></u><u></u></span></p>
                        <p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16""> </span><span style="font-size:12pt"><u></u><u></u></span></p>
                        <p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16""> </span><span style="font-size:12pt"><u></u><u></u></span></p>
                        <div id="m_3993873281129632795m_4184658542356538446mail-editor-reference-message-container">
                          <div>
                            <div>
                              <div style="border-right:none currentcolor;border-bottom:none currentcolor;border-left:none currentcolor;border-top:1pt solid currentcolor;padding:3pt 0in 0in">
                                <p class="MsoNormal" style="margin-bottom:12pt"><b><span style="font-size:12pt;color:black">From:
                                    </span></b><span style="font-size:12pt;color:black">openjfx-dev
                                    <<a href="mailto:openjfx-dev-retn@openjdk.org" target="_blank">openjfx-dev-retn@openjdk.org</a>>
                                    on behalf of Michael Strauß <<a href="mailto:michaelstrau2@gmail.com" target="_blank">michaelstrau2@gmail.com</a>><br>
                                    <b>Date: </b>Wednesday, October 23,
                                    2024 at 10:05<br>
                                    <b>To: </b><br>
                                    <b>Cc: </b><a href="mailto:openjfx-dev@openjdk.org" target="_blank">openjfx-dev@openjdk.org</a>
                                    <<a href="mailto:openjfx-dev@openjdk.org" target="_blank">openjfx-dev@openjdk.org</a>><br>
                                    <b>Subject: </b>Re: Proposal: Focus
                                    Traversal API</span><span style="font-size:12pt"><u></u><u></u></span></p>
                              </div>
                              <div>
                                <p class="MsoNormal"><span style="font-size:11pt">Maybe we
                                    can polish the naming a bit:<br>
                                    <br>
                                    When used as a transitive verb,
                                    "traverse" means (according to<br>
                                    Merriam-Webster): to go or travel
                                    across or over, to move or pass<br>
                                    along or through.<br>
                                    <br>
                                    MW gives the example: "light rays
                                    traversing a crystal". So one thing<br>
                                    is moving (light rays), while the
                                    other thing is static (a crystal).<br>
                                    Cambridge gives the example "Stanley
                                    traversed the continent from west<br>
                                    to east." Again, "Stanley" is
                                    moving, "the continent" is static.<br>
                                    <br>
                                    Since "traverseFocus" is a
                                    transitive verb followed by a direct
                                    noun,<br>
                                    it sounds to me like "focus" is the
                                    thing that can be traversed over<br>
                                    or across.<br>
                                    As an analogy, let's call the method
                                    "traverseContinent" for a moment.<br>
                                    It becomes obvious that "continent"
                                    is the space which is traveled<br>
                                    across, and not the thing
                                    travelling.<br>
                                    <br>
                                    In our case, "focus" is the moving
                                    thing, not the thing that it is<br>
                                    moved across. I would use something
                                    like "moveFocus", "shiftFocus", or<br>
                                    something along those lines.<br>
                                    <br>
                                    As for "TraversalDirection", I think
                                    it is acceptable, but I'll note<br>
                                    that to me, "direction" implies one
                                    of the four directional modes, not<br>
                                    the two logical modes (previous and
                                    next).</span><span style="font-size:12pt"><u></u><u></u></span></p>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </blockquote>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
  </div>

</blockquote></div>