Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

Searching tool to detect copies of source code

Thread view: 
moi - 22 Nov 2005 08:56 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.