Hello,
what tool provide an help to transform copies of source code into calls
to one common method in java?
Example:
* original
public void drawCellSmooth(int w, int h) {
if (w < 3 || h < 3)
return;
...
}
public void drawCellNormal(int w, int h) {
if (w < 3 || h < 3)
return;
...
}
* result
private boolean checkWidthHeight(int w, int h) {
return (w < 3 || h < 3);
}
public void drawCellSmooth(int w, int h) {
if (checkWidthHeight(w, h))
return;
...
}
public void drawCellNormal(int w, int h) {
if (checkWidthHeight(w, h))
return;
...
}
Other features are searched:
* detection of all the similar number to transform them into constants
* detection of same source code
* detection of almost same source code
- variable name are different
- the code is not exactly the same
* similar class which should be integrated into a hirarchy
* etc...
Any help appreciated
Ingo R. Homann - 22 Nov 2005 10:54 GMT
Hi,
> what tool provide an help to transform copies of source code into calls
> to one common method in java?
[quoted text clipped - 7 lines]
> * similar class which should be integrated into a hirarchy
> * etc...
Some "code auditing" tools can find such redundant code, e.g.
"checkstyle". I am not sure if (not to say "I doubt that") they can deal
with different variable names and so on.
I also do not know if (and I doubt that) there are any tools that
"provide an help to transform copies" (semi-)automatically (except in
very easy cases), since this can be done in very different ways
depending on how similar the code really is.
Ciao,
Ingo