Refactoring if(variable == CONSTANT) into if(CONSTANT == variable) [message #3805] |
Thu, 24 April 2003 04:51  |
Eclipse User |
|
|
|
Hi,
I am new to eclipse jdt. Exploring I chanced upon the Refactoring wizards.
They are great, like rename a class and by refactoring apply the change
through out the project (even in comments/ java docs). Thats really superb.
I have a specific refactoring requirement. Is it possible?
Normally in Java in "if" stmts we write:
if(varaible_name == IConstants.CONSTANT_VALUE) { ...
CONSTANT_VALUE is declared as a public static final in IConstants.java
However becuase of a typo if "==" is typed as "=" (single = sign)
The java compiler will not crib as it is syntactically valid.
But debuging such typo's in complex code is a big head ache.
My personal style in such case's is to put the constant on the left hand
side.
Like:
if(IConstants.CONSTANT_VALUE == varaible_name) { ...
But now given the fantastic Reafactoring wizards in eclipse will it be
able to refactor
if(varaible_name == IConstants.CONSTANT_VALUE) { ...
into
if(IConstants.CONSTANT_VALUE == varaible_name) { ...
of course this does not apply if I am not using constants in my if stmt.
Any comments ?
rgds
g1
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05582 seconds