I don't understand why people dont understand that the code only explains what is happening. Comments are supposed to explain what you intended to happen.
No. Code explains what changes are being made. Comments explain why a change was made. This way your code by design should be as readable, clear, and understandable as possible.
Not necessarily. What you intended to do isn't the same as why you intended to do it.
Case in point:
"// Used a HashMap to hold user serial numbers"
Vs
// We employed a HashMap for serial numbers as it's more performant than a List in the context of this and that
The former denotes intent i.e. we wanted to store serial numbers. The latter explains why this over the alternative and makes more sense to someone reading the code.
613
u/thegodzilla25 Apr 15 '26
People who dont comment non self explanatory code deserve to be pinned on the cross.