JSPF = Java Support Politely & Fast ... although I have plans to ditch
the P :)
> On Jan 4, 1:47 pm, Ralf <
r.bied...@googlemail.com> wrote:
> > > How do I add this second object and still keep things loosely-
> > > coupled? How do I keep the implementation part of the whole SQL
> > > plugin yet still be able to instantiate a bunch of them?
> The reason I don't want to include it with the main program is that -
> although unlikely - different "SqlPlugins" may need different
> implementations of "Sql". I can define an interface for "Sql" that
> the rest of the world can know about, but how do I then deliver the
> object itself at runtime? Make it another plugin? (Except I read
> elsewhere that you can't instantiate a plugin more than once.)
Ah, you mean Sql is a class, not an interface. Well, yes, in that case
you can either:
1) Bundle Sql with the main app. In that case everyone can use it, but
is strongly coupled to it.
2) Bundle various Sqls with (each of) the plugins. Plugins remain
independent but you need to "copy" code.
3) Provide a (set of) dedicated Sql provider plugin(s). However this
is almost similar to 1)
Best solution depends on a number of factors. For example, how likely
is it that you Sql class needs to be replaced / bug fixed? Frankly I
don't know if there is a best way to solve it, and I used all three
variants in various projects. You could try to ship a robust BaseSQL
or something with 1) which does 90% of the job and who needs it can
extend it. Same could be done with 3). Alternatively, if your build
system is automated enough, 2) is probably a solid solution. In that
case you could automatically enclose an Sql instance when you pack a
plugin.
Let me know if you find a silver bullet.
Cheers,
Ralf