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 / September 2006

Tip: Looking for answers? Try searching our database.

Cleaning up - unused variables, classes, etc.

Thread view: 
morten.norgaard@uni-c.dk - 21 Aug 2006 10:04 GMT
Hello,

  I'm taking over a huge single-programmer project. I've poked around
in the code and noticed a heap of unused variables, classes, routines -
and now I'm looking for a way to automatically get rid of these,
without having to sift through it all, line (many!) by line. Does
anyone know of a programming environment or possibly a designated
application that might assist me in this?

Thank you very much in advance,

Morten
Robert Klemme - 21 Aug 2006 10:09 GMT
> Hello,
>
[quoted text clipped - 4 lines]
> anyone know of a programming environment or possibly a designated
> application that might assist me in this?

Eclipse warnings cover some of these aspects.  Other than that you
probably want a code coverage tool.  HTH

Kind regards

    robert
Soren Kuula - 21 Aug 2006 10:15 GMT
> Hello,
>
[quoted text clipped - 4 lines]
> anyone know of a programming environment or possibly a designated
> application that might assist me in this?

Eclipse can highlight unused variables and methods. Well, it will only
highlight them if they are private; otherwise there would be no way to
know that they are not used (by some other code outside the project).

You will have to tighten up the Errors/Warnings settings under Compiler,
under Java, under Preferences.

Poor you. I will probably be doing the same soon, but I wonder if it's
worth the time to delete unused code. Probably not. One reason is,
unused classes will not even be loaded at runtime, so there is little
harm in just leaving them.

Søren
Thomas Weidenfeller - 22 Aug 2006 09:06 GMT
> Poor you. I will probably be doing the same soon, but I wonder if it's
> worth the time to delete unused code. Probably not. One reason is,
> unused classes will not even be loaded at runtime, so there is little
> harm in just leaving them.

There is a lot of harm unused classes can do. Not so much to your
application, but to your development project. They eat up resources.
E.g. people waste time with them trying to understand and maintain them.
Get rid of unused code as soon as possible.

/Thomas
Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/

Michael Rauscher - 21 Aug 2006 10:26 GMT
morten.norgaard@uni-c.dk schrieb:
> Hello,
>
[quoted text clipped - 4 lines]
> anyone know of a programming environment or possibly a designated
> application that might assist me in this?

Haven't tried it, but PMD [1] sounds to be the right thing.

Bye
Michael

[1] http://pmd.sourceforge.net/
Chris Brat - 21 Aug 2006 11:09 GMT
For class internals :

Download the CheckStyle project from Sourceforge,  set up a list of
style checks i.e. unused variables, redundant and unused imports, empty
for loops, redundant modifiers, redundant throws.

Not sure about a tool that identifies all unused classes tho.

> Hello,
>
[quoted text clipped - 8 lines]
>
> Morten
Morten Nørgaard - 22 Aug 2006 17:33 GMT
Chris Brat skrev:
> For class internals :
>
> Download the CheckStyle project from Sourceforge,  set up a list of
> style checks i.e. unused variables, redundant and unused imports, empty
> for loops, redundant modifiers, redundant throws.

Hi, thank all for your replies. CheckStyle was a very helpful tool.
Morten Nørgaard - 23 Aug 2006 21:18 GMT
Morten Nørgaard skrev:
> Chris Brat skrev:
>> For class internals :
[quoted text clipped - 4 lines]
>
> Hi, thank all for your replies. CheckStyle was a very helpful tool.

Turns out the proguard obcuscator is adept at discovering dead code,
actually.
Morten Nørgaard - 19 Sep 2006 07:31 GMT
Morten Nørgaard skrev:

> Hi, thank all for your replies. CheckStyle was a very helpful tool.

P.S. In addition I've had great succes with the free ProGuard
obfuscator, that'll shrink code as well as provide a list (if desired)
of unused classes, methods and variables. Check it out.

Best,

Morten
IchBin - 19 Sep 2006 07:38 GMT
> Morten Nørgaard skrev:
>
[quoted text clipped - 7 lines]
>
> Morten

Yes, I second that notion about ProGuard. Besides the obfuscation it
does do a nice job as a class file shrinker and optimizer. Always liked
this open source project.

http://proguard.sourceforge.net

Signature

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA              http://weconsultants.phpnet.us
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor,  Regular Guy (1952-)



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



©2008 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.