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
-
Write comments, if some of them are useless, chances are over time someone will delete it, but useful ones will stay forever
-
Code shows the what and how, comments tell the why.
At best, comments are not needed as the code is as close to an English text describing the feature as possible. -
nicofee1747yComment why something is done this way. If you need to work around a bug in library xy state that in a comment. If you banged your head against the table for a hour before realizing that something does not behave as expected leave a comment to avoid the next person having to go through the same process. If you make a decision or assumption, e.g. expecting time in ms vs. seconds document that
-
nicofee1747yIf something is a dirty hack, document that or else the next person to look at it might think it is a good way of doing it
-
TheZk617yThey're not exclusives. You can write auto explained code and comment the things that you think they need more explanation or will be faster to understand with that comment.
-
Root825317yComment the why, the potential issues, caveats, assumptions, etc. Anything that will help you understand the code after being absent for six months.
-
cursee171597yBoth are good advice but for different person.
If you are like super veterans coder, the advice on top is for you. (I don't know who, maybe Linus)
Below one for others. -
Ma30h56476yDon't explain your code, but write irrelevant comments. Preferably funny ones for next developers
So, what should I do?
rant