Question

Once a method is marked as deprecated, are there any tools which replace these methods with non-deprecated workarounds ?

Was it helpful?

Solution

Automated tools could only reasonably handle cases where there's a new preferred method or class to use to accomplish exactly the same task. Any case where a method is deprecated because of defective design (think anything dealing with date's in Java) or because a "better" way is now supported (think AWT to Swing or SWT) requires far to much thought to be automated.

In short, no there are no such tools. I doubt there ever will be any in the future as well.

OTHER TIPS

If you would like to do this automatically - no.

The tool is called a programmer.


The reason is that the tools would need to profoundly understand both the deprecation, the 'un-deprecation' , your program and the target programming language.

For instance, java.util.Date.setMonth is deprecated in favour of Calendar.set(Calendar.MONTH, int month).

That is a non-trivial change to apply, since it requires replacing object instantiations, method calls, taking into account synchronisation. Actually nightmarish to do automatically.

Usually, you should use something like regexps, ANTLR or JavaCC for implementing your own tool.

Besides, some IDEs offers relatively higher-level tools for facilitating this. In IntelliJ IDEA these are "Structural Search and Replace" and "Migrate" refactoring.

I can't see how this would work at the moment. Typically at least some thought needs to go into changing the client code. Ideally the deprecated method will include a comment saying, "Use method X instead, passing in null as the final parameter" or something similar, but only in the simplest cases could this be fully automated. Often there'll be something like "If you need to deal with null entries, use X. Otherwise, use Y."

(In addition, even in the simplest cases, there's no current way of representing the transformation in a machine-readable format - basically the appropriate protocol hasn't been defined as far as I'm aware.)

It's a nice idea, but I suspect that to implement it in a useful way would introduce more complexity than it would remove. Additionally, I'd be very wary of a tool doing this for me completely automatically - I'd probably want to preview every change anyway. At that point, it usually wouldn't save much time over doing it manually to start with.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top