24
OttkO
4y

Commented all of my code. More than 1000 lines, teacher didn't read it....

Comments
  • 3
    I feel you...
  • 4
    Did you get credit for the all important commenting? Don't worry, you are building habits that will be valued in your professional career.
  • 16
    I've been coding for over 20 years and In my experience, less comments and more readable and clean code are better.

    When you write code you will generally find that the code changes but the comments don't and then in a years time when you come back to the code the comments don't actually describe what's going on but rather what used to happen before the bug fixes, extensions and refactors happened.

    Using meaningful variables and cleaner structure mean that the code is self documenting. Before I check anything in I try to explain it to myself and if I find it getting overly complicated or difficult to explain its generally wrong. Code reviews also pull you up on the control flow, syntax and readability.
  • 5
    Too many comments means your code is too complicated and not well organized. Commenting should be for overall stuff not line by line.
  • 2
    @manFrame I agree with you. I didn't write 1000 lines of comments xD
  • 1
    I have to agree wirh @bluescreen on this one
  • 1
    @bluescreen comments should be updated too.
  • 2
    @mrec yes, but rarely are. Too many comments detract from the readability of the code which is why it's better practice to make your code self documenting.

    If your methods are sufficiently succinct you also don't have many paths of execution either making them easier to follow and ultimately unit test.

    Liken a class to a short story, each method is a paragraph of that story, if you can read the story easily it should make sense to everyone. Comments are like someone standing next to you talking endlessly while you read, they detract from the story!
  • 0
    @RemeJuan I don't like when people say that comments are not needed. Even if you have very good code it can help speed up things a lot with good commenting.
  • 0
    @bluescreen 100% agreed. And Everybody should read clean code by oncle bob
  • 0
    @RemeJuan @bluescreen I agree that the codes should be documented and tested. But I think comments are still necessary to make the development much easier. Documentation != comments. Comments are often used for complex logics. I am not saying the codes arent readable, what I want is to make the development alot easier for the next developer. If you had time to update the docs and tests, I dont think updating a 1 liner comment would hurt.
  • 0
    @RemeJuan Okay, well goodluck!
Add Comment