• ttyybb@lemmy.world
    link
    fedilink
    arrow-up
    93
    arrow-down
    1
    ·
    1 day ago

    A skilled programmer can make self documenting code, so I always document mine.

    • MotoAsh@piefed.social
      link
      fedilink
      English
      arrow-up
      18
      arrow-down
      2
      ·
      edit-2
      1 day ago

      Nah. No code actually documents itself. Ever. Anyone who says they can is an idiot that doesn’t understand the purpose of comments and docs.

      Code can never describe intent, context, or consequences unless you read every line of code in every library and framework used, and every external call. Especially if they aren’t doing “fail fast” correctly.

        • MotoAsh@piefed.social
          link
          fedilink
          English
          arrow-up
          10
          ·
          edit-2
          24 hours ago

          I did not say comments should directly explain what the code is obviously attempting to do.

          • ChickenLadyLovesLife@lemmy.world
            link
            fedilink
            English
            arrow-up
            11
            ·
            edit-2
            19 hours ago

            My favorite thing about the “all comments are bad” crowd is that their first example is almost always something like this:

            // Add 1 to x
            x = x + 1
            

            Like, nobody that thinks comments are good and important would ever add a useless comment like that. The point of commenting is to add documentation (usually the only form of documentation that a future developer is ever going to read) only to code that would otherwise be inscrutable.

            • Hudell@lemmy.dbzer0.com
              link
              fedilink
              English
              arrow-up
              2
              ·
              edit-2
              14 hours ago

              You’d think that, and yet I’ve once worked in a project in a fortune 500 company that basically wouldn’t even compile if we didn’t add comments like that. No kidding the compiler enforced specific comment patterns so if you had a line do x = x + 1, it would not compile if it was not preceded by a comment that started with “Add” and included “1” and “to x”. Even in dev mode if you wanted to just try something you had to comment everything.

              The original dev was super proud of this tools that generated HTML documentation about everything based on those comments. And the whole documentation was stuff like:

              *price*: The price
              
    • SeductiveTortoise@piefed.social
      link
      fedilink
      English
      arrow-up
      22
      ·
      1 day ago

      I inherited a code base probably written by a squirrel, and the first thing I did was to write documentation on infrastructure, business logic, architecture, deployment and whatever. I had to read everything anyways, because the guy handing it over had no idea what it did and left the company shortly after. It’s fine now, but that path was horrible.