What's the best practice to eliminate a number of related methods?

I want to abandon the method. It calls some helper methods that are now deprecated and is done in several places by testing that is also deprecated. In other words, I have a set of related methods / classes / tests throughout the project that are part of the same deprecation and should be removed at the same time.

When I come back later and try to remove the top level method, how can I be sure I have found all related stuff? Obviously, I can just leave my own notes that will tell me which related methods to delete. Otherwise, I can: 1) remove the endpoint, 2) search for failed tests and remove them; 3) rely on the IDE to find methods that are no longer in use and remove them too, but that seems vulnerable to me.

Is there a standard practice for deprecating a set of related methods / classes / tests to ensure they are all removed at the same time later?

+3


source to share


3 answers


The best practice is to use some sort of project / issue tracking -

create a task (ex: JIRA-224) and write what needs to be replaced and how.

add comment to all methods:



/**
 * method that does nothing
 *
 * @deprecated will be removed in JIRA-224.  
 */
@Deprecated
public void old() {
// .....
}

      

when you are ready, the person assigned to the task can search all files for "JIRA-224" and remove the methods.

+3


source


Use the @java.lang.Deprecated

on method . Don't forget about the javadoc:



/**
 * Does some thing .
 *
 * @deprecated use {@link #new()} instead.  
 */
@Deprecated
public void old() {
// ...
}

      

+2


source


I do not know of a specific practice or even a tool for this. Where: Tools like eclipse can easily give you warnings about unused private methods.

Anyway, I would suggest just "take notes". Meaning - Open a defect in your bug tracker and simply list the methods and tests that you are going to remove later. Thus, you have one place that describes your plan.

And as said: there are tools that talk about unused methods. Just run the tool before removing deprecated methods. Then run it again and then re-create new messages that were added when the tool was run again.

0


source







All Articles