• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Local or Network based connection

 
Sanjeev Kumar
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can somebody explain the following paragraph from the FBN assignment!
"The user interface should connect to the database using either a local or a network based connection according to user choice."
I am using RMI for network communication.
Sanjeev
 
Paul Smiley
Ranch Hand
Posts: 244
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe that this refers to you determining where the client is located - if in the same JVM, do not use RMI, but if remote, use it. That's the way I'm going to approach it, anyway...
 
Sanjeev Kumar
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul,
But, why double work. Even if you are working with single VM the RMI network will support that.
Sanjeev
 
Paul Smiley
Ranch Hand
Posts: 244
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my instructions under "Overall Architecture" it says:
"Additionally, the program must be able to work in a non-networked mode. In this mode, the database and user interface run in the same VM and no networking is performed. The user must be able to select the operating mode, although it is acceptable that the program stay in one mode once it has started up."
So - my instructions at least - say that you have to code it both ways, with one passing the networking (sockets or RMI) altogether. This makes sense in the real world also, as someone local shouldn't have to go through the overhead of networking for a local client.
Sounds like a good place for overloaded methods...


[This message has been edited by Paul Smiley (edited December 29, 2000).]
 
Jerry Pulley
Ranch Hand
Posts: 221
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...or the Adapter pattern
 
Paul Smiley
Ranch Hand
Posts: 244
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not familiar with that Jerry. Do you have a link or a reference to info about it?
 
Jerry Pulley
Ranch Hand
Posts: 221
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul,
Yes, go to http://c2.com/cgi/wiki?PatternIndex for tons of useful pattern info. In fact, be sure and bookmark http://www.cetus-links.de, it's a gold mine.
I used Adapter here because I had both Database and RemoteDatabase interfaces - they were almost identical but RemoteDatabase had a RemoteException on every method (of course). By writing an adapter class I'm able to program the client UI solely in terms of Database. In local mode, I use a subclass of Data which implements Database. In RMI mode, I get a RemoteDatabase from the server and plug it into the adapter, which handles all the RemoteExceptions.
Jerry
[This message has been edited by Jerry Pulley (edited December 29, 2000).]
 
Paul Smiley
Ranch Hand
Posts: 244
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jerry! That's a LOT of information!
Paul
 
Sanjeev Kumar
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jerry and Paul!
Using Adapter class is a great idea. I will follow that.
Sanjeev
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic