This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Boggitt and Scarper : RMI Design

 
Sudhansu Pati
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Andrew,
I created this new thread. Here is the link to the previous thread.
http://www.coderanch.com/t/184275/java-developer-SCJD/certification/RMI-Design-Following-Max-Book

According to you, since IOException is a parent of RemoteException, so the DataService don't need to raise RemoteException, rather it can raise IOException. The other reason is to keep DataService flexible for both remote and local use.

In that case, I guess I have to modify the methods to throw IOException instead of RemoteException.
DataService.java


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 ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Suds,
According to [Andrew], since IOException is a parent of RemoteException, so the DataService don't need to raise RemoteException, rather it can raise IOException.

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
 
Sudhansu Pati
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Andrew. Now I understand why Max made the DBClient generic. Yours and Marks suggestions helped me a lot.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic