I have two interfaces Inquiry and Validatable
and I also have two classes ErrorReport and FunctionQuery implements Inquiry and Validatable both.
What is the best choice when I have a logic that uses a combination of two interfaces' operation?
I know that I can separate it into two logic using Inquiry and Validatable, but the logic is combined so If I separate it, it makes other duplication.
I tried like below, but, I realized this hierarchy is not appropriate because Validatable is not a generalization of Inquiry in my application.
approach at first
public interface Inquiry extends Validatable {
...
}
and classes like this.
public class ErrorReport implements Inquiry{
...
}
public class FunctionQuery implements Inquiry {
...
}
new approach
So I create an interface like below.
public interface ValidatableInquiry extends Inquiry,Validatable{
...
}
and classes
public class ErrorReport implements ValidatableInquiry {
...
}
public class FunctionQuery implements ValidatableInquiry {
...
}
I think the new approach is better than the first, but I can't be assured. Is it the right approach? and Is there a better alternative?