• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Should RemoteConnection extend LocalConnection?

 
Patrick Cobbett
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an two interfaces,

and..

Then i have..

-this class behaves as an adapter, to adapt the Data interface to the Connection interface. They have the subtle difference that Connection throws an IOException when operations are performed on it.
This class basically delegates the work on to Data.

Then my RemoteConnectionImpl operates identically to LocalConnection with the exception of the lock and unlock methods.
Would it not make sense for RemoteConnectionImpl to extend LocalConnection and override the lock methods? It can export itself rather than extending UnicastRemoteObject. We are saying that a RemoteConnectionImpl is a LocalConnection which can be remotely exported.
After all, the server object is always a connection to a local database, but we are just saying that it also implements to declare that can also be exported remotely.
Therefore, the class declaration would be:
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This isn't a bad idea @ all. I can see you going either way with it. However, in a real world application, I probably wouldn't do it. Reason? I'd like for my RemoteConnection class and my LocalConnection class to be able to grow /evolve without having side effects on each other.
M
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic