Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why using a variable name "temp" considered a bad practice?

Tags:

People also ask

Why do we use temp variables?

In computer programming, a temporary variable is a variable with short lifetime, usually to hold data that will soon be discarded, or before it can be placed at a more permanent memory location. Because it is short-lived, it is usually declared as a local variable, i.e., a variable with local scope.

Is it bad to have long variable names?

Most functions only contain two or three variables, so a long name is unnecessary.

Why is it important to pick a good name for a variable?

Variables are so important to the code that they deserve a good name that accurately describes their purpose. Sometimes a bad name can be the difference between a fellow developer understanding what everything does at first glance and not having any clue where to begin. It's likely that we've all been there.

What makes a variable name illegal?

No other characters are permitted in the variable name. Specifically, spaces are not permitted in the variable names, as variable name must be a single word. Variable name may not start with a digit or underscore, and may not end with an underscore. Double underscores are not permitted in variable name.


Whenever i put up a code for review from professional programmers they tend to point out that "using a variable named temp is bad" but no one seems to know why.

Why is it considered bad ?