I was reading another thread regarding RMI design. The link is http://www.coderanch.com/t/179821/java-developer-SCJD/certification/Design-questions-RMI . In that link Peter den Haan explained a strategy to implement the RMI. According to his explanation, DataService can have all methods raise RemoteException. If a class implementing the interfaces is for local connection, just ignore the RemoteException. One doesn't have to throw all the exceptions in the implementing class that were raised in the interface methods. That way Dataservice can be used for both local and remote use. I am not sure which is a correct design or both ? [ October 02, 2003: Message edited by: Mark Spritzler ]
I fixed your code so that the thread doesn't distort the size. I am in the belief that follows Peter's suggestion. I had my interface throw RemoteExceptions, and the local implementation just ignored that Exception. Mark
Ummm, I was explaining how it works in Max's DVD Store application. I was not necessarily advocating it for your design.
I am not sure which is a correct design or both ?
I believe either approach is acceptable. The advantage to having your interface throw IOException is that it is not tied to RMI. If you (or the client) later decide to go with sockets, the same interface works very well. Whereas if your interface throws RMIException, then not only will it have to be rewritten for Sockets, but the existing signature will probably confuse the socket client writer (why do I have to catch RMIException when I am not using RMI). The advantage of throwing RMIExceptions is that it makes it more obvious to the junior programmer that they have to be catching network specific exceptions. Regards, Andrew