• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

any manual or book about designing some plug-able library like JDBC?

 
raminaa niilian
Ranch Hand
Posts: 551
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?


thanks
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic