• BorgDrone@lemmy.one
    link
    fedilink
    arrow-up
    28
    ·
    1 year ago

    Good code is self-explanatory. You should only comment your code if it does something unexpectedly complicated.

    The code shows what is being done. The comments should explain the why.

    • Pasta Dental@sh.itjust.works
      link
      fedilink
      arrow-up
      11
      ·
      edit-2
      1 year ago

      Yes. This 1000x. I hate it at work when I come across code that was written 3 years ago that has literally no traces of why it’s there and a quick summary of what it does. Especially because that code is always the most abbreviated spaghetti you’ve ever seen. People should stop thinking (their) code documents itself because 99.999% of programmers cannot do it right.

      I really like the Google way of coding: assume the person reading the code is the most 1337 programmer ever, BUT that this person knows absolutely nothing about the project

      • BorgDrone@lemmy.one
        link
        fedilink
        arrow-up
        4
        ·
        1 year ago

        Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.