I am at a stage where I have to refactor my code to accomodate future changes without changing mehtod signatures.
I have like 10 methods that take about 5 method parameters.
Couple of these methods are called recursively.
And few are called from other methods.
The input parameters from one method are passed to other methods.
The role of the input parameters vary based on the method.
Example:
private void createElem(Element doc, String factor1, String factor2, String factorOwner){
runElem(factor1,factor2,factorOwner);
Element elem = getElem(factor1, factorOwner);
doc.addContent(elem);
}
private Element getElem(String factorOwner, String factor){
/*some mainframe rule is called with rule owner as factor owner*/
}
In the example, factors are like the input criteria to the rule engine and factorOwner will define which rule to run.
As it is obvious that based on the function, different rules need to be processed.
I see that there could be potential increase in the input criteria.
in which case, I don't want to change the method signature to take that new factor as the method parameter.
I thought of using a value object called Factors that holds all the input crtieria.
But the problem is with the recursive calls as the role of the factor depends on the method in which it is executing, I need to add logic to update this value object in each method and I cannot retain previous values else I need to create new value object each time, which can be a overhead.
Any Ideas how to refactor such code, where there can be potential increase in the mehtod parameters.