• 9point6@lemmy.world
    link
    fedilink
    arrow-up
    10
    arrow-down
    6
    ·
    9 months ago

    The app working isn’t good enough, it needs to be maintainable. From a professional perspective, unmaintainable code is useless code.

    Code that mutates everywhere is generally harder to reason about and therefore harder to maintain, so just don’t do it (unless there’s literally no other practical way, but genuinely these are very rare cases)

    • ByGourou@sh.itjust.works
      link
      fedilink
      arrow-up
      1
      ·
      9 months ago

      I personally disagree, forcing yourself to use non mutable variables only leads to longer and more convoluted code.

      • 9point6@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        9 months ago

        Fair play, I guess we’re probably just gonna disagree.

        In my experience I’d say mutable code (larger than anything other than toy examples) always results in more time spent fixing bugs down the line, predominantly because it’s objectively harder for humans to reason about multiple one to many relationships rather than multiple one to one relationships. I’d say because you need to think about all possible states of the set of mutable variables in your code in order to completely understand it (and I don’t just mean understanding the intended purpose of the code, I mean understanding everything that code is capable of doing), that usually results in a more convoluted implementation than the pretty linear way you typically read functional code.

        Longer code is practically always better if it’s easier to understand than the shorter alternative. Software engineers aren’t employed to play code golf, they’re employed to write maintainable software. Though I’ll say ultra high performance applications might be the exception here—but 99% of engineers aren’t doing anything like that.

        I’m always happy to be convinced otherwise, but I’ve never seen a convincing argument