Reputation: 635
I currently work on a tracking project using a GPS receiver and a modem which sends the GPS positions to a server. Since this year there is a new modem available with an upgraded firmware library. The hardware design team at my company developed a new hardware using the new modem.
My problem is now: How can I build my application for both modem types from the same sources?
What I mean by that is: In the new firmware library there are some classes
and methods available which I can't use with the old modem and the old
firmware library. I use NetBeans as my IDE and therefore I can create easily different
ant configurations to build the application for both modem types,
but how do I implement that in my code. I can't have parts of the
new firmware library in my code since it wouldn't even compile, I have to
somehow "dynamically" link the correct firmware library. How is this done in Java?
Furthermore, the company which produces the modems has changed their company
name, and all packages which I import are now com.new_name.bla;
instead of
com.old_name.bla;
And that's mostly in all of my source files. I'm sure there is a way to solve this problem in Java. Has maybe somebody a good example for such an issue?
Upvotes: 1
Views: 55
Reputation: 4347
You could create a single interface that encapsulates the behaviour of the 2 libraries. In your code you would only use that interface. You would only need to write something that transforms each of the libraries to an implementation of that interface.
I believe this is the Bridge design pattern
Upvotes: 2