• Drop_All_Users@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    11 months ago

    Code documentation is like sex, when it’s good it’s great, and when it’s not good…it’s still better then no documentation.

    • zesty@lemmy.ca
      link
      fedilink
      arrow-up
      1
      ·
      11 months ago

      I disagree. When comments are essentially just a rephrasing of the class/method name or arguments it is not helpful and anything that is not helpful is cluttering up the code and making it harder to quickly see what the code is doing. I’d rather have no comments than comments like that.

      • nothacking@discuss.tchncs.de
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        11 months ago

        I reserve comments for explaining why a section of code is needed or explaining how a complex algorithm works.

        i = 0; // Set i to 0 is pointless.

        if (last_output_vertex[i] == bounds[i]->length - 1) contibuting_bounds[i] = NULL; // stop outputting a bound if the entire bound has been output is helpful.

        • JonEFive@midwest.social
          link
          fedilink
          arrow-up
          1
          ·
          11 months ago

          Comments can also be useful for explaining what the code is intended to do when debugging.

          “Hey this function says it should return the number of apples, but looks like someone, not saying who, but someone had a brain fart and typed oranges in one variable. Who wrote this code anyway?”

          -Last edited by JonEFive in 2021-

          Past me sucks.

        • bloodfoot@programming.dev
          link
          fedilink
          English
          arrow-up
          1
          ·
          edit-2
          11 months ago

          And if you’re male.

          Edit: FFS does no one realize that women experience sex differently from men? Bad sex with an oblivious partner can be downright painful for a woman. The same is typically not true for men. My point was not that women don’t have sex or that they don’t enjoy sex. My point is that they don’t experience it the same way as men.