Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Did you get credit for the all important commenting? Don't worry, you are building habits that will be valued in your professional career.
-
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. -
manFrame9488yToo many comments means your code is too complicated and not well organized. Commenting should be for overall stuff not line by line.
-
@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! -
Xevion1578y@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.
-
ignoRANT1318y@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.
Related Rants
Commented all of my code. More than 1000 lines, teacher didn't read it....
undefined
comments