Cleaning up - unused variables, classes, etc.

M

morten.norgaard

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
 
R

Robert Klemme

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?

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

Kind regards

robert
 
S

Soren Kuula

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?

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
 
M

Michael Rauscher

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?

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

Bye
Michael

[1] http://pmd.sourceforge.net/
 
C

Chris Brat

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.
 
T

Thomas Weidenfeller

Soren said:
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
 
?

=?ISO-8859-1?Q?Morten_N=F8rgaard?=

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.
 
?

=?ISO-8859-1?Q?Morten_N=F8rgaard?=

Morten Nørgaard skrev:
Chris Brat skrev:

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

Turns out the proguard obcuscator is adept at discovering dead code,
actually.
 
?

=?ISO-8859-1?Q?Morten_N=F8rgaard?=

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
 
I

IchBin

Morten said:
Morten Nørgaard skrev:



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

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

--
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-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top