Should I reuse variables?
Posted
by
IAdapter
on Programmers
See other posts from Programmers
or by IAdapter
Published on 2011-10-21T08:08:26Z
Indexed on
2011/11/12
18:06 UTC
Read the original article
Hit count: 434
Should I reuse variables?
I know that many best practice say you should not do it, however later when different developer is debugging the code and have 3 variables that look a like and only difference is that they are created in different places in the code he might be confused. unit-testing is a great example of this.
However I do know that best practice are most of the time against it. For example they say not to "overide" method parameters.
Best practice are even are against nulling the previous variables (in Java there is Sonar that has warning when you assign null to variable that you don't need to do it to call garbage collector since Java6. you cant always control what warnings are turned off, most of the time the default is on)
© Programmers or respective owner