Quote:
Originally Posted by k0nr4d
Im not gonna say im against commenting because its sometimes useful when something is done complicated or strange for some specific reason, but the fact is if someone cant figure out what a piece of code does from looking at it, they have no business editing it.
As long as you use self-explainatory function names and variables...
|
That's missing the whole point of commenting. Commenting is for the "why" not the "what". Take for example:
int x = 5; // Declare a new int and set it to 5.
The above is useless because you know what the line does. However:
int x = 5; // This is our initial case as our function is not defined for x < 5.
Is not useless because it might not be readily apparent that said function isn't defined for values < 5. This is a simple example and yeah, in production code there would probably be a line in the method like if (x < 5) throw new InvalidArgumentException(x); so one could infer the restriction on the input, but it should definitely be commented.
This is especially useful in the case of financial or technical software (what I develop).