Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is "temp" ever a good variable name?

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.

like image 361
Tim Avatar asked Mar 12 '11 20:03

Tim


People also ask

Is temp a valid variable name?

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 .

What do you name a temp variable?

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).

What variable names are acceptable?

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.


1 Answers

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 ;)

like image 62
stefan Avatar answered Oct 08 '22 13:10

stefan