mercredi 22 novembre 2017

Java - Refactor almost identical methods

I have a method which looks something like this:

private void method(final Param one, final Param two) {
    Code Block
    CallToAnotherMethod() 
}

This method is called from 2 places. In one of the places, I want to call the entire method as is. In the second place, I want to only execute the Code Block but not the CallToAnotherMethod().

How should I go about refactoring this? Implementing 2 methods with 99% of the same code does not seem elegant.

Thanks in advance for the suggestions.

Aucun commentaire:

Enregistrer un commentaire