Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Local And Remote Mode

 
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
 
ranger
Posts: 17346
11
Mac IntelliJ IDE 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
 
When people don’t understand what you are doing they call you crazy. But this tiny ad just doesn't care:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic