P
Philipp
Hello
I've been running TPTP static analysis in Eclipse over my code, and it
complains about:
"Always place constants on the left side of the equals()"
Example code:
if (fileExtension.substring(0, 1).equals(".")){
fileExtension = fileExtension.substring(1); // get rid of the dot
}
wants to be fixed to:
if (".".equals( fileExtension.substring(0, 1) )){
fileExtension = fileExtension.substring(1); // get rid of the dot
}
Why is it better to have constants on left side of equals() ?
In my opinion the first code is much more readable than the second. Is
readability of higher priority than such coding best practices?
Thanks for your answers
Philipp
I've been running TPTP static analysis in Eclipse over my code, and it
complains about:
"Always place constants on the left side of the equals()"
Example code:
if (fileExtension.substring(0, 1).equals(".")){
fileExtension = fileExtension.substring(1); // get rid of the dot
}
wants to be fixed to:
if (".".equals( fileExtension.substring(0, 1) )){
fileExtension = fileExtension.substring(1); // get rid of the dot
}
Why is it better to have constants on left side of equals() ?
In my opinion the first code is much more readable than the second. Is
readability of higher priority than such coding best practices?
Thanks for your answers
Philipp