• henfredemars@infosec.pub
    link
    fedilink
    English
    arrow-up
    6
    ·
    6 months ago

    I worked with a developer who insisted on using the shortest names possible. God I hated debugging his code.

    I’m talking variable names like AAxynj. Everything looking like matrix math.

    • redcalcium@lemmy.institute
      link
      fedilink
      arrow-up
      3
      ·
      edit-2
      6 months ago

      Ah, must’ve been a fortran developer. I swear they have this ability to make the shortest yet the least memorable variable names. E.g. was the variable called APFLWS or APFLWD? Impossible to remember without going back and forth to recheck the definition. Autocomplete won’t help you because both variables exist.

      • mkwt@lemmy.world
        link
        fedilink
        arrow-up
        3
        ·
        6 months ago

        And you can write more than six characters, but only the first six are recognized. So APFLWSAC and APFLWSAF are really the same variable.

        And without namespaces, company policy reserves the first two characters for module prefix and Hungarian notation.

      • nogooduser@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        ·
        6 months ago

        I don’t understand why people think that it’s acceptable.

        As developers, we’ve had it drummed into us from day one that variable names are important and shouldn’t be one or two letters.

        Yet developers deliberately alias an easy to read table name such as “customer” into “c” because that’s the first letter of the table. I’m sure that it’s more work to do that with auto completion meaning that you don’t even need to type out “customer”.

        • xmunk@sh.itjust.works
          link
          fedilink
          arrow-up
          1
          ·
          6 months ago

          Especially when you also have company and county tables. It forces people to look up what the c is aliased to before beginning to comprehend what you’re doing.

  • PoolloverNathan@programming.dev
    link
    fedilink
    arrow-up
    3
    ·
    6 months ago

    I present to you quality variable names. (and a Mount Rustmore)

    (Reconfigure(f), 'c') => {
        let mut p: Vec<&str> = vec![];
        loop {
            match args.next() {
                Some(k) => {
                    if k == "=" {
                        match args.next() {
                            None => q("need value for Rc"),
                            Some(v) => u(
                                f,
                                |f| Box::new(
                                    |c| {
                                        f(c);
                                        c.set(p.iter().copied(), v);
                                        for e in p {
                                            unsafe {
                                                Box::<str>::from_raw(
                                                    std::mem::transmute(e)
                                                );
                                            }
                                        }
                                    }
                                )
                            )
                        };
                        break
                    } else {
                        p.push(Box::leak(k.into()));
                    }
                }
                None => error("need path element or = for Rc"),
            }
        }
    },
    
  • JATtho@sopuli.xyz
    link
    fedilink
    arrow-up
    3
    ·
    6 months ago

    name your function as malloc() and see to world burn and generate bugs at factorial rate.

    • trolololol@lemmy.world
      link
      fedilink
      arrow-up
      2
      arrow-down
      1
      ·
      6 months ago

      If you name it malloc it will be easy to notice. On the other hand if you call it free…

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

    Single character variable names are my pet peeve. I even name iterator variables a real word instead of “i” now… (although writing the OG low level for loops is kinda rare for me now)

    Naming things “x”… shudder. Well, the entire world is getting to see how that idea transpires hahah

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

      X, y, and z should only be used when working with things with dimensions larger than 1. Indexing into a 2D array, x and y are great uses. I’m also totally fine with i and j for indexer/iterator when appropriate, but I hate when people try to make short variable names for no good reason. We have auto-complete just about everywhere now. Make the names descriptive. There’s literally no reason not to.

    • Mikelius@lemmy.ml
      link
      fedilink
      arrow-up
      0
      ·
      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
        0
        ·
        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
          1
          ·
          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.

  • Malix@sopuli.xyz
    link
    fedilink
    arrow-up
    2
    ·
    6 months ago

    installing operating system: 15 minutes, give or take.

    give a name to the computer: 45 minutes

    • SturgiesYrFase@lemmy.ml
      link
      fedilink
      arrow-up
      1
      ·
      6 months ago

      I’ve got that shit on lockdown man.
      I name all my devices “Fuck0ff” followed by a 3 letter descriptor of what it is. E.g. - my windows install is Fuck0ffDTW for Desktop Windows, my Garuda install is Fuck0ffDTG for Desktop Garuda(it’s a flavour of Arch, btw)

  • ZILtoid1991@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    6 months ago

    Then you realize your code is undebuggable because half the functions and variables have single-letter names or called foo, bar, baz, etc.

  • steventhedev@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    6 months ago

    Older C compilers would truncate a variable name if it was too long, so VeryLongGlobalConstantInsideALibraryInSeconds might accidentally collide with VeryLongGlobalConstantInsideALibraryInMinutes.

    Legend says that they used to do it after a single letter with Dennis declaring “26 variables ought to be enough for anyone”.

    • LostXOR@fedia.io
      link
      fedilink
      arrow-up
      2
      ·
      6 months ago

      Who needs private variables when you can generate cryptographically secure variable names? Much better security.

    • rufus@discuss.tchncs.de
      link
      fedilink
      arrow-up
      2
      ·
      6 months ago

      Make it 63 (31?) to align with what C99 can distinguish.

      Also: I really like unicode in identifiers. So if at all possible don’t just have a random string of letters and numbers, make sure to include greek letters and all the funny emojis. (I just forgot which languages and compilers etc allow that.)

  • Destide@feddit.uk
    link
    fedilink
    English
    arrow-up
    1
    ·
    6 months ago

    It took me too long to figure out the I in an if statement was just integer

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

    Since a lot of the english words i know i learned from minecraft, in a farming simulator i named tilled soil"hoed"

    I had multiple variables like int isHoed