• 9point6@lemmy.world
    link
    fedilink
    arrow-up
    18
    arrow-down
    1
    ·
    edit-2
    12 hours ago

    Oh, I guess I’m a stoneager with a penchant for functional elitism then.

    Though I will admit OOP is valid for involved data modelling, everything else should be functional though.

    I’ve also trained myself out of most short variable names for maintainability reasons

    • Valmond@lemmy.dbzer0.com
      link
      fedilink
      arrow-up
      1
      ·
      5 hours ago

      Yeah, it’s wild people “don’t like OOP” 100%, it’s like most good things, don’t put it where it shouldn’t be.

      • ozymandias117@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        ·
        3 hours ago

        If you’re really going down that route, you need to also remember that even the C programmed Linux Kernel is highly OOP

    • masterspace@lemmy.ca
      link
      fedilink
      English
      arrow-up
      14
      ·
      edit-2
      10 hours ago

      Outside of the for loop counters i and j, short variable names are awful. Coming back to old code written with abr var nams is like talking to someone in the military who just constantly throws out jargon and acronyms that they know you don’t know.

      But so are Java style ObserverFactoryManagerTemplateMachinistTemplater names.

      There’s a sweet middle ground of short, but actually descriptive name. Sometimes it’s not possible but that’s usually a code organization / language / framework smell.

      Too short variable names is usually a sign that you need to use a proper ide, with auto complete, or that you need to use a proper build process that will minify your code after the fact.

      Too long names are usually a sign that your module of code (function, class, namespace, etc) is too large, or that your language/framework naming conventions are too strict, or the language doesn’t encapsulate scope properly.

      • marcos@lemmy.world
        link
        fedilink
        arrow-up
        5
        ·
        7 hours ago

        The length of variable and function names should be proportional to the size of the code that can potentially call them. And preferably segmented in namespaces, explicit modules, or something like that.

      • red_tomato@lemmy.world
        link
        fedilink
        arrow-up
        7
        ·
        edit-2
        10 hours ago

        Outside of the for loop counters i and j, short variable names are awful.

        I’ve started to prefer writing it out as ”index” or ”iteration” even in for loop counters. It’s easier to read, and not much harder to type.

            • silasmariner@programming.dev
              link
              fedilink
              arrow-up
              2
              ·
              edit-2
              4 hours ago

              I is a vowel too but you sure can!

              Edit: also I noticed you dropped one ‘y’ but not the others. Is this an accident or some subtlety to do with y’s ‘semi-vowel’ status? To be discussed.

        • FishFace@piefed.social
          link
          fedilink
          English
          arrow-up
          3
          arrow-down
          1
          ·
          10 hours ago

          Keeping things that can be on one line to one line is a good reason to use short variable names where it won’t be confusing. Writing “iteration” sounds absolutely perverse!

          The thing is, everyone understands i and j. The reason calling variables hcv or iid is dumb is because noone knows what that means - quite a different situation.

          • red_tomato@lemmy.world
            link
            fedilink
            arrow-up
            3
            ·
            9 hours ago

            Writing “iteration” sounds absolutely perverse!

            I like it to make it clear when the for loop is about iterating lists and when it’s not. For example, the iterations in Monte Carlo algorithms doesn’t correspond to items in a list.

        • masterspace@lemmy.ca
          link
          fedilink
          English
          arrow-up
          2
          ·
          10 hours ago

          I typically do too, or userIndex or something for nested loops, but I will accept i and j for the first two levels of nesting when reviewing a PR because they’re such a convention. I wouldn’t accept variable names like that anywhere else though and try and avoid them myself.