Are there any plugins in eclipse based IDEs which can suggest a better way to refactor any particular statement (in Java), for example
Let's say you have the following code:
if ( someString.equals("whatImLookingFor") ) {
}
The plugin should offer to flip the equals to:
if ( "whatImLookingFor".equals( someString ) ) {
}
Such that, this helps in enforcing better coding practices
As per the one of the suggestions given below by @Peter Lawrey, it was possible in IntelliJ Idea IDE through Flip Commutative Method call, which as I searched was part of Intentions Power Pack plugins from Jetbrains (back in 2004).
Is there any equivalent of this plugin in Eclipse ?
Version of IDE I searched for plugin is : IBM Rational Software Architect 9.6.1, but nothing relevant was found
No because as you told they are not equivalent.
Refactoring create a code with the same behaviour.
The refactored code must be equivalent to the original. In this case it is not, that happens for example because if
someStringisnullthe first conditionwill generate a
NullPointerException, while the second conditionis evaluated to
false. It is not the ide that could refactor a code in a code with a different behaviour also if the new behaviour can be considered a better code.