• @jarfil@beehaw.org
    link
    fedilink
    12
    edit-2
    1 year 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”.

  • @Hazzia@discuss.tchncs.de
    link
    fedilink
    281 year 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
      link
      fedilink
      English
      71 year 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
      221 year 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.

  • @Goodie@lemmy.world
    link
    fedilink
    151 year 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.

  • @Agent641@lemmy.world
    link
    fedilink
    141 year 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.

  • @Zangoose@lemmy.one
    link
    fedilink
    3
    edit-2
    1 year 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(...)
    
  • @sparkle@lemm.ee
    link
    fedilink
    Cymraeg
    3
    edit-2
    1 year ago

    in general, adjectives and verbs after nouns because it’s more organized/easier to search/filter. as god intended.

  • @roon@lemmy.ml
    link
    fedilink
    English
    161 year 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

    • janAkali
      link
      fedilink
      English
      111 year ago

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

    • @verstra@programming.dev
      link
      fedilink
      27
      edit-2
      1 year 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
        link
        fedilink
        English
        51 year ago

        Heathen! You must alphabetize all the things!

        Like seriously. It makes scanning code much easier.

        • @lunarul@lemmy.world
          link
          fedilink
          41 year 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
            1
            edit-2
            1 year 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
              11 year 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”)

          • ddh
            link
            fedilink
            English
            41 year ago

            And “red big car” is wrong.

  • @rekabis@lemmy.ca
    link
    fedilink
    761 year 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
      25
      edit-2
      1 year 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.

      • redfellow
        link
        fedilink
        31 year ago

        I put all those in different files

        compont/functions/foo.ext etc.

      • @rekabis@lemmy.ca
        link
        fedilink
        91 year 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.

        • @deadbeef79000@lemmy.nz
          link
          fedilink
          5
          edit-2
          1 year ago

          We probably have slightly different work processes.

          I’m more likely to be making “foo” functionally complete and then making “bar” complete than I am to be making all my dialogs functional then all my tabs/whatever.

          This comes from TDD where I’m making a test pass for “foo”, once done, I’ll do the same for “bar”.

          Though it’s even more likely these are different files entirely, rendering the arguments moot.

    • @Static_Rocket@lemmy.world
      link
      fedilink
      English
      71 year 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
      31 year 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.

  • @onlinepersona@programming.dev
    link
    fedilink
    English
    201 year 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