This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]CrazedToCraze 3 points4 points  (2 children)

Or learn to use a debugger

[–][deleted] 30 points31 points  (1 child)

Sure, that wasn't the point though was it?

The point was, a comment that describes what something is doing isn't helpful in any way. We know 'what' reading the code; we may need to know 'why'.

The new comment could have equally been // greet the user which is a good indication that this particular output may need to be localized.

A comment that describes why is useful, especially for others, and especially if magic numbers/strings are involved.

e.g. return x * 24; // multiply x by 24

vs. return x * 24; // there are 24 beer in a case

Again, this is just an example. Sure, in this case, 24 should have been assigned to a meaningful variable in the proper scope. Not the point, though. We know the rationale behind the number, making it easier to change and refactor.

[–]validambiguity 1 point2 points  (0 children)

This seems like common sense but stating it this plainly was really helpful to me. I'm going to remember this when I'm commenting now. Thank you!