• Zangoose@lemmy.one
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    3 months ago

    I know I’m late to this but here’s my (probably insane?) take. We use Subject-Verb-Object in English right? So, hear me out:

    dialog_create_tab(...)
    dialog_open_file(...)
    dialog_close_file(...)
    
    • verstra@programming.dev
      link
      fedilink
      arrow-up
      0
      ·
      edit-2
      3 months ago

      This is the real big-endian way. So your things line-up when you have all of these:

      file_dialogue_open
      file_dialogue_close
      file_dropdown_open
      file_rename
      directory_remove
      

      If I were designing a natural language, I’d put adjectives after the nouns, so you start with the important things first:

      car big red

      instead of

      big red car

      • dohpaz42@lemmy.world
        link
        fedilink
        English
        arrow-up
        0
        ·
        3 months ago

        Heathen! You must alphabetize all the things!

        Like seriously. It makes scanning code much easier.

      • funkless_eck@sh.itjust.works
        link
        fedilink
        arrow-up
        0
        ·
        3 months ago

        If I were designing a natural language, I’d put adjectives after the nouns, so you start with the important things first

        So - French?

        • lunarul@lemmy.world
          link
          fedilink
          arrow-up
          0
          ·
          3 months ago

          The thing is that in French, Spanish, etc. it still makes sense if you put the adjective before the noun, even if it might sound weird in some cases. An adjective is an adjective and a noun is a noun.

          But English is positional. Where you put a word gives it its function. So “red car” and “car red” mean different things.

          • deadbeef79000@lemmy.nz
            link
            fedilink
            arrow-up
            0
            ·
            edit-2
            3 months ago

            That’s because they are romance languages. They come from Latin where word order is irrelevant as each “word” has a different form for the specific use.

            • lunarul@lemmy.world
              link
              fedilink
              arrow-up
              0
              ·
              3 months ago

              Yes, that’s what I said. My native language is a romance language too. And after speaking it her whole life, my wife has trouble getting the grasp of how in English swapping two words completely changes the meaning of what she’s saying (especially when it’s two nouns, like e.g. “parent council”)

    • janAkali@lemmy.one
      link
      fedilink
      English
      arrow-up
      0
      ·
      3 months ago

      To be fair, it’s also missing open_dialog_file, dialog_open_file and most crucially file_open_dialog

  • Goodie@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    3 months ago

    Whatever is more useful goes first.

    For example, if this we’re a list of UI text strings, finding all of the dialogue options together might be useful.

    If, instead, this is a series of variables already around one dialogue, then finding the open or close bits together would be useful.

        • stufkes@lemmy.world
          link
          fedilink
          arrow-up
          0
          ·
          3 months ago

          Dialogue is UK English. But I just looked it up and apparently ‘dialog’ is a computer term, but should not be used on its own but rather in combination, such as ‘dialog box’.

          • smeg@feddit.uk
            link
            fedilink
            English
            arrow-up
            0
            ·
            3 months ago

            Americans sadly got there first and defined all the computer terms, that’s why it’s a TV programme but a computer program. I can deal with that though, helps distinguish computer things from real things!

  • Caveman@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    3 months ago

    I prefer everything to be how you would read it as text. So create_file_dialog it is. Honorable mention is to have it namespaced in a class or something which I think is best. file_dialog.create or dialog.create_file or even dialog.file.create

    • Bruno Finger@lemm.ee
      link
      fedilink
      arrow-up
      0
      ·
      3 months ago

      I agree. I say open door so the function should be named openDoor.

      Honestly nowadays none of that matter if you’re using any remotely modern IDE with good indexing and a sensible search, you can start typing however you mind works and it will find it no matter how it’s named.

    • sudo@programming.dev
      link
      fedilink
      arrow-up
      0
      ·
      3 months ago

      My method names are the same way but I aggressively sort things into modules etc so it comes out the other way.

      But if I was staring down dozens of these methods and no way to organize them, I’d start doing the sorted names just for ease of editing. L

  • RustyNova@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    3 months ago

    I don’t know and that’s the problem :(

    I keep asking myself what to choose, only for changing it a day after cursing myself to choose a stupid name.

    Big endiant is great for intellisense to quickly browse possibilities, since it groups it all in the same place. But that’s also a detriment when you know what you want. You can start typing without the prefix but you’ll have to go through the better suggestions of intellisense first.

    Little endiant is the same thing, but in reverse. Great when needed, but bad for browsing.

    Although I do have some fix I’m starting to use. But it’s not applicable everywhere, and not in every language.

    What I do is use module as prefix. Instead of dialogue_file_open, I create a file_open in the dialogue module, allowing either directly calling file_open, or dialogue::file_open. Using intellisense on the module allow for easy browsing too!

    Although in OP’s post I’d rather have file_open_dialogue as it convey the more significant meaning, being to open a file, first. Then “dialogue” is just the flavour on top

  • onlinepersona@programming.dev
    link
    fedilink
    English
    arrow-up
    0
    ·
    3 months ago

    I used to like the action followed by direct object format, until some time ago when trying to find methods or variables related to a specific object. If the action comes first, scanning for the object without an IDE means first reading unnecessary information about the action. That convinced me to opt for $object-$action in situations where it makes sense.

    For example in CSS, I often scan for the element, then the action, so $element-$action makes more sense. BEM kinda follows this. When dealing with the DOM in JS, that makes sense too button.fileDialogOpen(), button.fileDialogSend(), … makes more sense when searching.

    Of course one has to use it sensibly and where necessary. If you are writing a code that focuses more on actions than objects, putting the action first makes sense.

    A similar thing is definition order.

    def main(args):
      result = do_something(args.input)
      processed = process_result(result)
      transformed = transform_object(processed)
      return transformed.field
    
    def do_something(some_input):
      ...
    
    def process_result(result):
      ...
    
    def transform_object(obj):
      ...
    

    I find this much easier to follow than if main were defined last, because main is obviously the most important method and everything else is used by it. A flattened dependency tree is how these definitions make sense to me or how I would read them as newbie to a codebase.

    Anti Commercial-AI license