• Mikelius@lemmy.ml
    link
    fedilink
    arrow-up
    20
    arrow-down
    1
    ·
    6 months ago

    I hate short variable names in general too, but am okay with them for iterators where i and j represent only indices, and when x/y/z represent coordinates (like a for loop going over x coordinates). In most cases I actually prefer this since it keeps me from having to think about whether I’m looking at an integer iterator or object/dictionary iterator loop, as long as the loop remains short. When it gets to be ridiculous in size, even i and j are annoying. Any other short names are a no go for me though. And my god, the abbreviations… Those are the worst.

    • FrostyCaveman@lemm.ee
      link
      fedilink
      arrow-up
      5
      ·
      6 months ago

      That’s very reasonable, I can get behind that. (my stance is a partly irrational overreaction and I’m totally aware of it lol)

      Abbreviations are definitely annoying. My least favourite thing to do with them is “Hungarian notation”. It’s like… in a statically typed context it’s useless, and in a dynamically typed context it’s like… kind of a sign you need to refactor

      • Cethin@lemmy.zip
        link
        fedilink
        English
        arrow-up
        3
        ·
        6 months ago

        Hungarian notation makes sense in a dynamically typed usage (which I despise, but this essentially makes them notationally typed at least) or where you’re editor/IDE is so simple it can’t give you more information, which I can’t see ever being the case in the modern day.

      • Redkey@programming.dev
        link
        fedilink
        arrow-up
        1
        ·
        6 months ago

        Most people use the term “Hungarian Notation” to mean only adding an indicator of type to a variable or function name. While this is one of the ways in which it has been used (and actually made sense in certain old environments, although those days are long, long behind us now), it’s not the only way that it can be used.

        We can use the same concept (prepending or appending an indicator from a standard selection) to denote other, more useful categories that the environment won’t keep straight for us, or won’t warn us about in easy-to-understand ways. In my own projects I usually append a single letter to the ends of my variable names to indicate scope, which helps me stay more modular, and also allows me to choose sensible variable names without fear of clashing with something else I’ve forgotten about.