Why using a variable name “temp” considered a bad practice?

前端 未结 2 2120
抹茶落季
抹茶落季 2021-02-14 22:31

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

2条回答
  •  遥遥无期
    2021-02-14 23:13

    It's because temp suggests something about the longevity of the variable (temporary) but nothing about the meaning or significance of its content. Variables are generally best named to reflect what their underlying value is intended to represent.

提交回复
热议问题