• cbazero@programming.dev
      link
      fedilink
      arrow-up
      18
      arrow-down
      4
      ·
      11 hours ago

      You dont. Thats why you write code that explains itself. For higher level info you write documentation.

        • Maalus@lemmy.world
          link
          fedilink
          arrow-up
          6
          arrow-down
          3
          ·
          3 hours ago

          The only moment you write comments is when you are doing something extremely weird for a specific reason that will not be immediately obvious and you want to warn the person doing a refactor in the future. In any other case, writing self documenting code is the way. If you are unable to do that, then your code needs to be rewrtitten.

          • ruekk@lemm.ee
            link
            fedilink
            English
            arrow-up
            5
            arrow-down
            2
            ·
            2 hours ago

            Self documenting code is a myth as what’s self documenting to one person is not to the next. Code comments and process/workflow documentation is needed for a healthy codebase.

                • Maalus@lemmy.world
                  link
                  fedilink
                  arrow-up
                  1
                  arrow-down
                  2
                  ·
                  1 hour ago

                  Not really an opinion when most companies run on self documenting code since time immemorial.

              • zalgotext@sh.itjust.works
                link
                fedilink
                arrow-up
                1
                ·
                2 hours ago

                Try handing over your “self documenting code” to a junior dev who doesn’t know the language it’s written in and see how far they get with it.

                Now hand that exact same codebase with comments to the same junior dev, and I guarantee you they’ll get further than without the comments.

                • Maalus@lemmy.world
                  link
                  fedilink
                  arrow-up
                  1
                  ·
                  1 hour ago

                  I have given well documented code to plenty of juniors, it comes with being a senior dev / techlead. And it was perfectly understood. Maybe you simply don’t write self documenting code.