Comments in code are quite often a code smell. Let’s see what is suboptimal about comments and talk about some strategies to avoid them.

  • darklypure@kbin.social
    link
    fedilink
    arrow-up
    0
    ·
    10 months ago

    Having spent many times having to walk Technical Architects through code, explaining what it does, or trying to introduce new coders to software development, I comment line by line. It’s not just experienced coders that have to look at your code. I will never not do this.

    • burliman@lemm.ee
      link
      fedilink
      arrow-up
      0
      ·
      10 months ago

      This is a little bit of a case in point of why documentation should not be written by the teacher. It should be written by the student. The student takes no knowledge for granted and so will only repeat themselves insofar as they need to. The teacher will either repeat themselves consistently, or just leave massive gaps due to their preexisting knowledge. Even though it wouldn’t be practical for a coder to have some student document their code, I feel like this still illustrates the point. Also it means you have to constantly put yourselves in the shoes of some future student, which seems like a good practice anyway.