Sometimes I've been trying to come up with a good variable name for minutes, when I realize that it isn't worth the effort for this tiny loop. Is there any situation where it would be justified to call a variable "temp"?
Update: I should have been more clear since you are all programmers! I'm not looking for cases where "temp" actually describes the function of the variable, but cases where it means absolutely nothing at all.
A variable name is usually chosen in a way that describes the meaning and the role of its contained data. For example, a variable that holds a temperature value might be named temperature , temp , or even t .
Temporary variables are usually named with identifiers that abbreviate the word temporary, such as temp, tmp or simply t, or with common metasyntactic variable names, the most common of which are foo, bar, baz (see also foobar).
A variable name can only have letters (both uppercase and lowercase letters), digits and underscore. The first letter of a variable should be either a letter or an underscore. There is no rule on how long a variable name (identifier) can be.
Sure, if you do swapping by value;
int temp = a;
a = b;
b = temp;
Or if you use variable notation such as calc for calculation etc you should use temp for temperature ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With