• BaardFigur@lemmy.world
      link
      fedilink
      arrow-up
      19
      ·
      edit-2
      7 months ago

      Comment smart, don’t comment every line like this

      int i = 5; // Assigns the value 5 into the variable i.

      • Maalus@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        7 months ago

        Comment only in extraordinary situations, when something you read can confuse someone. And by that I mean the business logic, not that you used a method that’s confusing to people since they only know the basics of the language.

      • stebo02@sopuli.xyz
        link
        fedilink
        arrow-up
        1
        ·
        7 months ago

        I usually comment on whole groups of lines of code, so the goal of each part of the code is clear

    • RagingRobot@lemmy.world
      link
      fedilink
      arrow-up
      5
      ·
      edit-2
      7 months ago

      I would disagree. I love to use comments to format my code and separate the sections. I think it’s so beautiful. Also I love when libraries have ASCII art in the comments at the top of the main file lol. It makes the code more fun in my opinion.

      I went to college with a guy who would treat the code as art when presenting projects. His code was always beautiful. Not super functional but always beautiful. It always stuck with me. I want my code to always be functional and beautiful. Easy to read and a pleasure to work with. That’s my goal at least. Comments help with that.

      Also it depends on what the code is for haha