Hello I need to build application that has some general functionally (like collecting data analyzing and such .. ) But there is apart in the application that needs to communicated with third party application this third party Application can be from different every time , that is will use different communication protocol and will have slight different Interface. How can I design this section of the application? I was thinking that it will use plugins , that every third party application will Have its own plugin that will implement interface and I will have this well defined interface in the application side that always Will know what to expect. What do you think? Is there any pattern for this kind of task? Thanks
It's a good solution, and actually a typical cluster of patterns:
- you use the Strategy pattern to make the thirdparty library exchangable - the implementations for the single libraries will probably need to use the Adapter pattern to adapt their specific API to the generell plugin API, and - you will probably use some kind of Dependency Injection to tell the code which strategy to use
Does that help?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
posted 12 years ago
I didn�t understand the third part , I do know the strategy pattern and the adapter . But the injection part I didn�t understand
Have you worked with JDBC? That's an interesting design example because Sun defined a bunch of interfaces but didn't provide any implementation. The database vendor has to provide implementations that actually connect to a database. So in some sense, databases are plug-ins.
The JDBC spec tells the database vendor to manage everything starting from a static block in the driver class. When you say Class.forName(driver) that block executes, registers itself with JDBC and configures whatever it needs for the rest of the run. After that the driver can create instances of classes that implement ResultSet and so on.
That initialization is nifty but a little too magical for my tastes. Class.forName doesn't usually do anything quite so significant. I prefer the kind of injections mentioned in the paper Peer suggested.
At the high end of plug-in modules is OSGi. It's probably way beyond what you need now, but a bit of reading on it may give you some ideas. [ August 24, 2007: Message edited by: Stan James ]
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
posted 12 years ago
Hi thanks for the fast reply well yes i did worked with jdbc , and yes it seams this is what i need as a simple implementation , do you know links so i can read about it ? now im reading the :http://www.martinfowler.com/articles/injection.html
Every snowflake is perfect and unique. And every snowflake contains a very tiny ad.