Hi thank you for reading my post we have an application which some part of it (in term of implementation) changes for each customer and deployment. I thought that we can develop some interface that cover all of our requirement and develop several implementation for it, for each customer we can use any of those implementations. what i can not understand is how to design the library to be as plugable and easy to change as JDBC drivers.
is there any manual or help about designing this kind of functionality in an application?
Google for the Dependency Inversion Principle and Dependency Injection.
And then develop the library iteratively and incrementally, in the presence of a couple of different clients.
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
JDBC is a neat example. When we write programs that use JDBC we refer to all the goodies in java.sql. But if you browse to java.sql in the JavaDoc, you'll find that almost everything we use is really an interface. Sun doesn't provide any classes to support connections, resultsets, etc, only interfaces. The different database vendors have to provide classes that implement those interfaces.
We never know the names of those classes, and we never do "new" on them. So how do we get object instances? Through factories or some kind of creation helper.
Your plugin scheme can work the same way. Build a set of interfaces that your application uses for all its business level work. Build a set of implementation classes for each pluggable setup.
"Dependency Injection" is a neat style for doing this kind of thing. An "application assembler" component reads configuration and pushes the proper plugins to components that need them. That way the components have no dependency on the configurator or anything except the interfaces.
Does that answer the right question?
Ha! Ilja sneaked in there while I was typing! You and your cursed short answers! [ December 16, 2006: 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
This is too good an opportunity to plug my own stuff to pass it up, so in a shameless act of self-promotion let me point you to a recent JavaRanch Journal article I've written that deals with the subject of adding a plugin mechanism to Java code.
Ping & DNS - updated with new look and Ping home screen widget