Comment from my group project teammate. You don’t need to comment every line lol

    • Doc Avid Mornington@midwest.social
      link
      fedilink
      English
      arrow-up
      1
      ·
      5 months ago

      It’s better to have useful comments. Long odds are that somebody who writes comments like this absolutely isn’t writing useful comments as well - in fact, I’m pretty sure I’ve never seen it happen. Comments like this increase cognitive overhead when reading code. Sure, I’d be happy to accept ten BS useless comments in exchange for also getting one good one, but that’s not the tradeoff in reality - it’s always six hundred garbage lines of comment in exchange for nothing at all. This kind of commenting usually isn’t the dev’s fault, though - somebody has told a junior dev that they need to comment thoroughly, without any real guidelines, and they’re just trying not to get fired or whatever.

    • henrikx@lemmy.dbzer0.com
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      5 months ago

      Universities often teach students to write a lot of comments, because you are required to learn and demonstrate your ability to translate between code and natural language. But this is one of the things that are different in professional environments.

      Every comment is a line to maintain in addition to the code it describes. And comments like this provide very little (if any) extra information that is not already available from reading the code. It is not uncommon for someone to alter the code that the comment is supposed to describe without changing the comment, resulting in comments that lie about what the code does, forcing you to read the code anyway.

      It’s like if you were bilingual, you don’t write every sentence in both languages, because that is twice as much text to maintain (and read).

      The exception of course, being if you are actually adding information that is not available in the code itself, such as why you did something a particular way.

    • Darohan@lemmy.zip
      link
      fedilink
      arrow-up
      0
      ·
      5 months ago

      Legit, I’ll take this over the undocumented spaghetti I too often see written by “professionals”.

      • Fal@yiffit.net
        link
        fedilink
        English
        arrow-up
        0
        arrow-down
        1
        ·
        5 months ago

        This is so wrong. I would absolutely prefer no comments over incorrect comments, which is exactly what happens when things get over commented