• alexdeathway@programming.dev
    link
    fedilink
    arrow-up
    5
    ·
    edit-2
    8 months ago

    First one are method name, second one are status name.

    
    def open_file_dialog(self):
           self.dialog_file_open = True
           pass
    
    

    Yoda level preference war.

    • Croquette@sh.itjust.works
      link
      fedilink
      arrow-up
      3
      ·
      8 months ago

      I tend to add is to booleans toreally differentiate between a method name and a status.

      def open_file_dialog(self):
          self.dialog_file_is_open = True
          pass
      

      That way, it’s easier for my dumb brain to spot which is which at a glance.

          • sus@programming.dev
            link
            fedilink
            arrow-up
            0
            ·
            edit-2
            8 months ago

            that works for 2 word names eg is_open or is_file, but in this case is_dialog_file_open is structured like a question, while dialog_file_is_open is structured like a statement

            • Rinox@feddit.it
              link
              fedilink
              arrow-up
              3
              ·
              8 months ago

              Doesn’t matter, the point is that, if it starts with “is” then you automatically know it’s a boolean.

  • rekabis@lemmy.ca
    link
    fedilink
    arrow-up
    5
    ·
    8 months ago

    There is a reason why little endian is preferred in virtually 100% of cases: sorting. Mentally or lexicographically, having the most important piece of information first will allow the correct item be found the fastest, or allow it to be discounted/ignored the quickest.

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

      That’s actually filtering not sorting.

      That being said, it’s more valuable (to me) to be able to find all my things for a topic quickly rather than type.

      Foo_dialog

      Foo_action

      Foo_map

      Bar_dialog

      Bar_action

      Bar_map

      Is superior IMHO.

      • rekabis@lemmy.ca
        link
        fedilink
        arrow-up
        1
        ·
        8 months ago

        If you are looking for Bar, it is highly likely that you are already looking specifically for a particular functionality - say, the action - for Bar. As such, it is irrelevant which method you use, both will get you to the function you need.

        Conversely, while it is likely you will want to look up all items that implement a particular functionality, it is much less likely you are going to ever need a complete listing of all functionality that an item employs; you will be targeting only one functionality for that item and will have that one functionality as the primary and concrete focus. Ergo, functionality comes first, followed by what item has that functionality.

    • Static_Rocket@lemmy.world
      link
      fedilink
      English
      arrow-up
      1
      ·
      8 months ago

      But also, sorting big endian automatically groups elements associated with common functions making search, completions, and snippets easier (if you use them). I’m torn

    • 33550336@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      8 months ago

      I was going to write something like this. You actually wrote about semantic order, but syntactically it is as much important e.g. it is easier to sort dates such as 2024-05-27 than 27.05.2024 in chronological order.

  • redcalcium@lemmy.institute
    link
    fedilink
    arrow-up
    3
    ·
    8 months ago

    I’m truly torn with this. The first one seems sensible (action -> target) and easier to read and reason about (especially with long names), while the other one looks more organized, naturally sortable and works great with any autocompletion system.

    • kunaltyagi@programming.dev
      link
      fedilink
      arrow-up
      2
      ·
      8 months ago

      We need a new framework, one that allows universal lookup, and makes life easier

      x = _.dialog.file.open
      y = _.open.file.dialog
      z = _.file.open.dialog
      a = _.file.dialog.open
      

      Once done, the formatter simply changes everything to _.open.file.dialog

      Let’s get this done JS peeps

      \s

        • bitwolf@lemmy.one
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          8 months ago

          Also a programmer and think method names would be conducive using little endian.

          TopicGet()
          TopicCreate()
          TopicDelete()
          

          Writing this I realize we do this implicitly in some instances.

          http.Get() -> httpGet()
          http.Post() -> httpPost()
          
  • Hazzia@discuss.tchncs.de
    link
    fedilink
    arrow-up
    3
    ·
    8 months ago

    Can’t remember which is which but if it’s organized in a top-down way (broad category first) that’s just easier to look at and find stuff in the file system. I don’t want to have to actually read and mentally process the names of every single file to figure out if it’s the one I need. Sure, the “human readable” names are fine and good when you don’t have hundreds of them you’re trying to look through, but big projects I find are way easier to parse with the category naming.

    • BlanketsWithSmallpox@lemmy.world
      link
      fedilink
      English
      arrow-up
      1
      ·
      8 months ago

      How any large organization gets away with not using YYYY-MM-DD format is beyond me.

      Taking over some of my previous directors files is like chaos.

      How anybody publishing entire internet memos without a date being on the first page is beyond me. Like wtf am I reading a PDF from 15 years ago or last month?

    • ooterness@lemmy.world
      link
      fedilink
      English
      arrow-up
      1
      ·
      8 months ago

      US Army logistics catalogs are organized this way. “Cookies, oatmeal” instead of “Oatmeal cookies” because it’s a lot easier to find what you need an a giant alphabetical list.

  • evatronic@lemm.ee
    link
    fedilink
    English
    arrow-up
    2
    ·
    8 months ago

    I do one, the other senior dev does the other. We fight about it in pull requests.

    • livingcoder@programming.dev
      link
      fedilink
      arrow-up
      1
      ·
      8 months ago

      Your team needs to have a coding standards meeting where you can describe the pros and cons of each approach. You guys shouldn’t be wasting time during PR reviews on the same argument. When that happens to me, it just feels like such a waste of time.

      • evatronic@lemm.ee
        link
        fedilink
        English
        arrow-up
        1
        ·
        8 months ago

        Preachin to the choir, friend. I’d get worked up about it but I’m paid the same regardless of how upset I get.

    • verstra@programming.dev
      link
      fedilink
      arrow-up
      0
      ·
      edit-2
      8 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

      • funkless_eck@sh.itjust.works
        link
        fedilink
        arrow-up
        0
        ·
        8 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
          1
          ·
          8 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.

  • Zangoose@lemmy.one
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    8 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(...)
    
  • Agent641@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    8 months ago

    I just name my variables a, b, c etc. If I have more than 26 variables in any given function, I name them aa, ab, ac, etc.

  • jarfil@beehaw.org
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    8 months ago

    Both:

    dialog_error = Dialog_plain.create_modal(error_text)
    

    Variable and class names go from more general to more particular, functions begin with a verb.

    Global functions are either “main”, or start with one of “debug”, “todo”, or “shit”.

  • Goodie@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    8 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.

  • roon@lemmy.ml
    link
    fedilink
    English
    arrow-up
    1
    ·
    8 months ago

    Powershell has a lint warning for functions that don’t follow Verb-Noun format, and verbs here are a list of approved verbs lol

        • stufkes@lemmy.world
          link
          fedilink
          arrow-up
          0
          ·
          8 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
            1
            ·
            8 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!