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
-
If it only explains why one line exists/one line then
foo(); //bar
is very fine. -
Lokuzt3078y@filthyranter if it's that short on a short file yeah. Large apps with big lines of code and huge amounts of code do not benefit of this
-
@Lokuzt I always do it. Well, my school lets us fucking do the stuff on paper anyway. -.-
-
Is that a bad practice? I always do this if the comment is short. And it can show up in the search result in case I have to do a global search.
-
g1abhi248ySeriously that's just an opinion. With no logic driven reason. There are more advantages to using it, just like seeing it in search results.
-
arekxv10548yOr better yet: Don't write the comment at all. If you named your function correctly that comment is completely not necessary.
-
I do this for short comments.
However like someone mentioned about longer comments, I prefer multiple lines of comment, each line with roughly 7 words. easy to scan through and does not mess with the flow of the code :) -
I do this when I am trying to comment if/else if/else blocks
if () { // do stuff
...
} else if () { // do other stuff
...
} else { // do other stuff
...
}
Related Rants
Please don't comment in front of the code like this:
doSomething(); // does something
Please just stahp
Do this:
// does something
doSomething();
Much better and friendly for everyone
undefined
wk26
commenting
code