J
Jama
Greetings,
When I build my libraries, I code to interfaces, which is clearly a
best practice. When programmers then create classes that use my
interfaces, they complain that the exceptions they want to throw are
not defined in my signature. For example:
public interface myInterface {
public void instantiateThisMethod();
}
is no good. People want interfaces like:
public interface myInterface {
public void instantiateThisMethod() throws Exception;
}
This gives the implementing programmer flexibility to throw any
exception they want. So now, all my interfaces have "throws Exception"
tacked on the end of every signature.
Is this a bad idea? What's the proper approach to defining exception
handling with interfaces from a best practices point of view?
Thanks,
J
When I build my libraries, I code to interfaces, which is clearly a
best practice. When programmers then create classes that use my
interfaces, they complain that the exceptions they want to throw are
not defined in my signature. For example:
public interface myInterface {
public void instantiateThisMethod();
}
is no good. People want interfaces like:
public interface myInterface {
public void instantiateThisMethod() throws Exception;
}
This gives the implementing programmer flexibility to throw any
exception they want. So now, all my interfaces have "throws Exception"
tacked on the end of every signature.
Is this a bad idea? What's the proper approach to defining exception
handling with interfaces from a best practices point of view?
Thanks,
J