• theherk@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    2 hours ago

    And your colleagues are probably correct with respect to this sort of «what it does» commenting. That can be counterproductive because if the code changes and the comment isn’t updated accordingly, it can be ambiguous. Better have the code be the singular source of truth. However, «why it does it» comments are another story and usually accepted by most as helpful.

    • Overshoot2648@lemm.ee
      link
      fedilink
      arrow-up
      1
      ·
      2 minutes ago

      I’ll add that you should have a comment anytime you are using some sort of algorithm to explain what it is and the expected result when it’s not intuitive or a complex math operation that isn’t immediately clear…