Deprecated methods: how important to fix?

K

kaeli

Hey all,

I just inherited some code for an applet. I have never made an applet. Yay
me.
Anyway, it's old code that has a bug, and I need to find and fix the bug. I
figured as long as I was doing that, I should get the code to use java 1.4
(it was made with something way before this) since all our browers here tend
to have 1.4xx.
So, I compiled it, and fixed most of the deprecated stuff, but I'm wondering
about these:

stop() in java.lang.Thread has been deprecated
action(java.awt.Event,java.lang.Object) in java.awt.Component has been
deprecated
handleEvent(java.awt.Event) in java.awt.Component has been deprecated

I've never made an applet, as I said, nor used the AWT components. I've never
done threads.
How hard are these to re-do, and should I bother? I'm only supposed to be
fixing a bug totally unrelated to these (at least as far as I know they're
unrelated...).
If YOU inherited the code, would you fix it or leave it?

TIA

--
--
~kaeli~
All I ask is the chance to prove that money cannot make me
happy.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
 
P

Paul Lutus

kaeli said:
Hey all,

I just inherited some code for an applet. I have never made an applet. Yay
me.
Anyway, it's old code that has a bug, and I need to find and fix the bug.
I figured as long as I was doing that, I should get the code to use java
1.4 (it was made with something way before this) since all our browers
here tend to have 1.4xx.
So, I compiled it, and fixed most of the deprecated stuff, but I'm
wondering about these:

stop() in java.lang.Thread has been deprecated

This one is very, very important to change. Stopping a thread can be
dangerous, and, of all deprecated methods, this one is at the top of the
list.

Preferred: Have the thread watch for a stop-flag and stop itself when it
detects the flag. Never try to stop a thread externally.
action(java.awt.Event,java.lang.Object) in java.awt.Component has been
deprecated
handleEvent(java.awt.Event) in java.awt.Component has been deprecated

These are important to change, and even more important not to use in new
code. But they are not as important as Thread.stop().
I've never made an applet, as I said, nor used the AWT components. I've
never done threads.
How hard are these to re-do, and should I bother? I'm only supposed to be
fixing a bug totally unrelated to these (at least as far as I know they're
unrelated...).
If YOU inherited the code, would you fix it or leave it?

I would fix it. In fact, I have gone through many of my old programs,
reworking the action and event handling code.

If the code only has a past, don't bother. If the code has a future, take it
more seriously.
 
A

Andrew Thompson

stop() in java.lang.Thread has been deprecated

/* old - stop the thread */
Thread.stop()

/* new */
run() {
while(stillAlive) {
...
}
}

...
// stop the thread
stillAlive = false;
action(java.awt.Event,java.lang.Object) in java.awt.Component has been
deprecated

Implement ActionListener on the applet and
Component.addActionListener(this);
handleEvent(java.awt.Event) in java.awt.Component has been deprecated

Should not be required if you implement
ActionListener, you simply detect the
event in actionPerformed() and do with
it as you wish.
How hard are these to re-do,

Not very, unless there are lots of components
to change, in which case it amounts to some
drudgery.
..and should I bother? I'm only supposed to be
fixing a bug totally unrelated to these (at least as far as I know they're
unrelated...).

I would tend to fix the bug first, I think,
unless you become convinced it *is* the problem.
If YOU inherited the code, would you fix it or leave it?

(waggles hand) Are they paying you extra to fix it?
Will you be working on the code again in the future?
Is the Applet likely to be used for years more?

I'd be tempted to fix them simply not for having to
put up with the irritation of the warning, though
sometimes such a 'pro-active' approach goes down
like a ton of bricks (..if anybody finds out).
 
E

Eric Sosman

kaeli said:
Hey all,

I just inherited some code for an applet. I have never made an applet. Yay
me.
Anyway, it's old code that has a bug, and I need to find and fix the bug. I
figured as long as I was doing that, I should get the code to use java 1.4
(it was made with something way before this) since all our browers here tend
to have 1.4xx.
So, I compiled it, and fixed most of the deprecated stuff, but I'm wondering
about these:

stop() in java.lang.Thread has been deprecated
action(java.awt.Event,java.lang.Object) in java.awt.Component has been
deprecated
handleEvent(java.awt.Event) in java.awt.Component has been deprecated

I've never made an applet, as I said, nor used the AWT components. I've never
done threads.
How hard are these to re-do, and should I bother? I'm only supposed to be
fixing a bug totally unrelated to these (at least as far as I know they're
unrelated...).
If YOU inherited the code, would you fix it or leave it?

There's no simple answer to this kind of question.
You need to assess how hard it would be to fix the program
and compare that to the amount of damage that a failure
would cause. Costs and benefits, benefits and costs.

One thing to keep in mind is that methods don't become
deprecated out of mere whim. Face it: A deprecated method
is an admission that the original design was deficient. If
someone draws a deep breath and confesses "I wuz wrong," you
must assume that he considers it more important to warn you
off than to save face for himself. A concern that prompts
us famously egotistical software types into an embarrassing
admission is worth paying some heed to.

The Javadoc for a deprecated method usually describes the
shortcomings of the original design, and what the consequences
of using the method might be. It also usually suggests a
substitute method, and this should give you an idea of the
difficulty of the fix. Consider the Javadoc as you decide to
fix or to let be.
 

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,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top