Peter wrote:
The second choice would require the client to be aware whether the DataInterface implementation it was using was local or remote. This would point to a flawed understanding of the interface concept. Interface implementations should satisfy the substitution rule for inheritance: wherever you are using an interface, you should be able to use any implementation of that interface in exactly the same way.
I absolutely agree. However, my point is that throwing a "method not supported" is as legitimate implementation as an empty method, or a method that actually does some work. For example, here is a javadoc for the getNameInNamespace() method in Sun's Context class:
"In naming systems for which the notion of full name does not make sense, OperationNotSupportedException is thrown."
By analogy, it doesn't make sense for a remote client to close the database on the server, hence the justification for throwing an exception.
Perhaps a method like this should not be in the interface in the first place (since it forces the implementing classes to provide a "fake" implementation), but that's a separate issue.
Eugene.
[ January 15, 2003: Message edited by: Eugene Kononov ]