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
-
I read the comment and then the code is clear. If I read the comment and the code is not clear, which is rare, then it's probably not correct. No logical connection, that's just how it usually is imo
-
We3D26521ythe problem with the comments is that most just don't update them when changing smth, so I trust them when they are mine and I know no one has changed anything there ;)
-
I don’t trust comments at all.
You probably heard it before but in case you didn’t:
Comments shouldn’t describe what the code does!
Comments should be rare and only applied to places where it’s unclear why the piece of code is there. Or why it is written this way rather than another way, if it’s unexpected or unusual.
Everything else should be self describing code with good names and structure and mostly without useless comments. -
@Lensflare interesting. How do you define when something is unusual enough to merit a comment?
-
We3D26521y@chaosesqueteam no, no and no. there is no way I write in the comments my mental state
and on the topic : yep the comments should be rare and only if the structure of the code does not easily show it's purpose -
We3D26521y@chaosesqueteam that's cool and all, but the comments are for all and mainly for the future maintainer ( even if that's you )
-
We3D26521y@chaosesqueteam like :
//had to smoke some weed to finish this
//too drunk to code - finish it tomorrow
//I think I take too many shrooms
nah, don't think that they will help me remember what I was thinking when writing the code... -
We3D26521y@chaosesqueteam may I should take the same shit too to bring the memory faster to that same save point ;)
-
@chaosesqueteam No. You can write comments for WIP code to remind you of the current state, but those comments should be removed after that part of the code is done.
Just imagine a code base full of comments about what the writers were thinking at that time, which is completely irrelevant by now. -
Never trust the comments. If you see any delete them. The code should be self documenting. Fucking comments always lie.
Raise your hand if you don’t trust the comments in code most of the time, and take at least a superficial look at the code block to ensure that it does what it says it does.
If you have any exceptions, please share.
random