let's say i have an interface as below
public interface ConditionChecker {
boolean isInCondition(Person p);
}
I want to create a new class implementing the above interface but i need to implement a function with another parameter
public class MacroConditionChecker implements ConditionChecker {
public boolean isInCondition(Person p, MacroView mv);
}
Two problems:
One: if i change the interface signature to boolean isInCondition(Person p, MacroView mv); then i need to update all the classes implementing ConditionChecker
Two: I want the consumers of ConditionChecker to just call isInCondition as-is
I think that means:
public class MacroConditionChecker implements ConditionChecker {
private static final MacroView mv;
public MacroConditionChecker(MacroView mv) {
this.mv = mv;
}
public boolean isInCondition(Person p){
// now i have access to MacroView
}
}
so, the only change i need is make at the time I decide to use MacroConditionChecker and the call to isInCondition is not changed
Am i on the right track? or Is there some way else to accomplish this?
or should i separate out MacroView as its own interface
public class MacroConditionChecker implements ConditionChecker implements MacroView
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)