|
|
|
|
|
by dextorious
5301 days ago
|
|
I can see how loop indexes (i) etc are nice to be short, but I don't see how the other stuff is valid, as opposed to a personal preference. Why is maxval a better name than MaximumValueUntilOverflow? The first lacks some extra information that I need to keep in mind every time I re-read that part of the code. And while the potential of overflow might be obvious, how about: minValueForTemperature instead of minval? |
|
Complex variable names ought to be avoided because, simply, they hammer the programmer with a bunch of information every time they are used. Usually, when reading code, you're trying to wrap your head around how a procedure operates rather than the specifics of what it's operating on. Often, if you need to know more about what a variable represents, it's sufficient to refer to its declaration.
Thusly, I prefer to name my variables so that one can pick up the general idea of what they're for from the name and then I document any additional information at the variable's declaration, either using a comment or via the type system.
So, this is how I'd handle your examples: