2 ms·
I mainly comment in two situations: When I wrote some weird code due to non-obvious reasons and want to clear up the reasoning; this makes later considerations
by alpaca128 7y ago
I mainly comment in two situations:
When I wrote some weird code due to non-obvious reasons and want to clear up the reasoning; this makes later considerations easier.
Or when I had difficulties understanding the meaning of a snippet and want to make it easier to read and understand in the future.
I get why many people say comments are bad, but that doesn't mean you should never use them. And the "why" comments are definitely the most helpful ones in my opinion, I agree; one can easily look at the expressions and function calls and understand what's happening, but sometimes I want to know why the code adds 1 to some index, and a single short comment can clear that up. And if the reasoning was incorrect then that comment also tells you what to throw away.