• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Local And Remote Mode

 
Anurag Mishra
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I had used a single interface between local and remote mode switching,
My Interface called FlightIntf used all the public methods of data class which throws remote exception. This interface is implemented by an adapter class called FlightAdapter on RemoteMode and this same interface is implemented by the Data class when application is running in Local mode. In my client I used this type of code:
FlightIntf intf;
private void localMode(){
try{
intf=(FlightIntf)new Data("db.db");
}catch(Ex...);
}
private void remoteMode(){
try{
intf=(FlightIntf)Naming.lookup(//+ Servername+ port.....);
}
Is this the right design plz help me out as soon as possible. I also want to know that this type of design comes under which pattern.
Anurag Mishra
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That looks good to me.
You have both implementing the Interface, so the client only has to know that it is using an object of that interface, whether it is in Local or Remote.
Who calls the methods localMode or remoteMode? Because the one who does, is like a Factory Design Pattern, so to speak.
As far as 2 classes implementing an interface, I don't know which Pattern that exactly falls under.
But the design looks like it works
Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic