4 ms·
Because it re-states what the code is saying, which makes it two things you wind up reading to absorb one fact. It also create two update points if that code ne
by sudhirj 8y ago
Because it re-states what the code is saying, which makes it two things you wind up reading to absorb one fact. It also create two update points if that code needs be changed.
I prefer that authors spend time to make sure the code is clear about what is happening, and use the comments to tell me why it's happening, and that too only when it's not obvious, or counterintuitive, or there for a special requirement.
Just wanted to point out that comments are not to be confused with documentation as comments, like Javadoc, Godoc strings. These need to be complete and verbose, especially if they code is a library or public.
- deleted 8y ago[deleted]
- zeth___ 8y agoIt doesn't. -1 could mean you're returning a success. I mean that would literally be true in Forth.
- yoz-y 8y agoIf the function returns magic numbers then that should be stated in the documentation comment.
- icebraining 8y agoYou're showing another problem with these comments: they're often ambiguous. Specifically, the message says "return on error", which to me doesn't mean it returns an error, but to you it did.
- watwut 8y agoIt just seem quite petty thing to get angry about. Reading those two things takes less then additional half second and on update you can delete the comment if you don't like it. I have seen project behind schedule and it was never because of tiny things like this. Also, you are likely to find out that comments like this are often result of people just auto-writing them at the moment e.g. writing it was faster then reflect on it. Which is not necessary good thing, but it is saving time in expense of little bit less effective code.
- sudhirj 8y agoThe comment is more a symptom than a cause of problems. If useless comments are added, they’re often an excuse for lazy code, in that it allows a way to say I can’t be bothered to write this better, I’ll just add a comment instead. Regarding time saving, I seriously doubt that code quality is proportional to time spent typing. Instead of typing two things I would prefer the author spent more time thinking and typing just one thing.