• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

client being aware of the mode 'local' or 'remote'

 
Rasika Chitnis
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have read some postings in this forum which say that the client should not be aware of the mode in which it connects to the database. I agree to it. But then, as I was finishing my client code, I came across a need to look at the mode. I want to call the 'close' method in Data class, from client only when the mode is local. That made me think again, and I realized that my client is using 'mode' for one more thing i.e. to decide if to instantiate Data or do a lookup for remote object.
why are we saying then, that client should not be aware of the mode ?
any feedback is appreciated. thanks
 
Angus MacCuish
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll need to know the mode to decide whether to use Local vs Remote, but other than that the mode should be irrelevant.
In remote mode close() can be an empty no-op implementation of this interface method, or it can call a similar method on the RMI object to notidy the server that the client has disconnected - may or may not be useful depending on your design.
Cheers
Gus
 
Angus MacCuish
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For 'notidy' read 'notify' !!
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indeed. You have this DataInterface (or whatever you called it) with a method called "close()". Now you have to carefully distinguish semantics (meaning) from implementation.
  • The meaning of the close() method is "I'm through with you, release all my resources".
  • In local mode, the entire database file is yours, so the implementation will be to close the file.
  • In networked mode, the database file is shared, but you may own a couple of locks because of application bugs or whatever. The implementation of close() may clean up any locks held by the client.
  • In other words, when you specify an interface you do not just specify a bunch of method signatures. You also specify what these methods mean, allowing code that uses the interface not to worry about the implementation. If this is not true, you may have correctly implemented the methods but you have failed to correctly implement the semantics.
    - Peter
    [This message has been edited by Peter den Haan (edited December 05, 2001).]
 
Rasika Chitnis
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, guys, for your feedback. It helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic