DEV Community

Discussion on: Bad Programming Habits

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
_garybell profile image
Gary Bell

Some code should be commented, for example any code which is very specific to a domain problem and appears counterintuitive.

Comments for the sake of comments - like "looping through array" - are annoying

Collapse
 
wildarg profile image
Pavel

Totally agree. I follow "Clean Code" by Robert Martin. If it needs to be commented, that means it's not clear enough

Thread Thread
 
mxldevs profile image
MxL Devs

Which can be a good thing of course, in case anyone reads this and thinks all good code must be self-explanatory.

"Code that is not clear" is not necessarily "bad code".

Collapse
 
uniquexor profile image
Algirdas

For the sake of no. 19, what drives me insane is people not writing comments :D Try debugging anything a bit more complex or code you see for the first time and you start appreciating comments quickly. Remember, what's self explanatory to you, might not be for someone else. Or for yourself in a year, for that matter... And I agree with Gary, not talking about arbitrary comments.

Collapse
 
evilprince2009 profile image
Ibne Nahian

That's why I said codes should be self explanatory.

Thread Thread
 
uniquexor profile image
Algirdas

And that's why I said "what's self explanatory to you, might not be for someone else" :D

Thread Thread
 
koekiewollie profile image
Koekiewollie

Think about this, comments are often not maintained well and can be misleading.
Better to have no comments, than misleading ones.
If the code is clear enough, comments are almost never needed.

Collapse
 
eunovo profile image
Oghenovo Usiwoma

Clean code should be self explanatory. It should rarely require comments

Collapse
 
gfalco77 profile image
gfalco77

Code can't never been self explanatory for everybody, you need the right comments at the right place. I don't like javadocs but sometimes a line of comment in the right place is all you need.

Collapse
 
pwuk profile image
Peter

Indeed, been caught out by our of date comments before.
Plus a lot of comments don't even make sense sometimes