Timeline for Using single characters for variable names in loops/exceptions
Current License: CC BY-SA 3.0
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 28, 2011 at 0:07 | comment | added | Konrad Rudolph | @nikie What information does “CenterOfGravity” impart then, in the context of a center of gravity? Exactly none, is my point. The only distinguishing information, and hence the only relevant information, is conferred by the coordinate names proper, x, y and z. If you really need to differentiate between different sets of coordinates, you better use appropriate structures, i.e. you have CenterOfGravity.x etc. Either way, the general use-case is always best expressed by an appropriate type, not the variable name proper. | |
| Apr 27, 2011 at 15:25 | comment | added | nikie | @Konrad Rudolph: To propose a more meaningful name, you have to know more about the meaning of the variable. Anything else is useless verbosity, that's my point. You'd have to know what these coordinates designate - e.g. if it's the position of the center of gravity, then xCenterOfGravity/yCenterOfGravity would be candidates. If the coordinates really don't have a meaning (as e.g. the X/Y members of a Point structure) then X/Y is fine. But in my experience that's the exception, not the rule. | |
| Apr 27, 2011 at 15:01 | comment | added | Konrad Rudolph | @nikie Well, propose a more meaningful name for coordinates then. | |
| Apr 27, 2011 at 12:55 | history | made wiki | Post Made Community Wiki | ||
| Apr 27, 2011 at 11:12 | comment | added | jwenting | I've done it, when running out of meaningful names to use when having to work under such rules, and I think most of us have experienced things like it :) | |
| Apr 27, 2011 at 10:50 | comment | added | nikie | I doubt Dan's coworker argued for adding useless noise characters like "iter" instead of "i" or "xCoord" instead of "x". Nobody would name their variables like that, except people who deliberately try to follow the letters of coding standards, but not their spirit. | |
| Apr 27, 2011 at 10:38 | comment | added | Nobody | Also event args are usually called e. Probably because its common practice to append EventArgs to the end of the parameter type name. | |
| Apr 27, 2011 at 10:37 | comment | added | Dan Atkinson | Thanks for your answer. Regarding x/y/z, this seems to have been the common usage for lambda in C# since its exception, and I've just gone with the community on it. In this case though x/y/z aren't related to coordinates, but are checking instances. So in C# .Where(x => x == 5) would be similar to a for loop statement if(i == 5) or if(myArray[i] == 5). | |
| Apr 27, 2011 at 10:28 | history | answered | jwenting | CC BY-SA 3.0 |