Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2007

Tip: Looking for answers? Try searching our database.

Advice on creating interface for plugins

Thread view: 
Shannon Lloyd - 17 Mar 2007 22:55 GMT
Hi,
I am writing an app which will permit plugins for various things,
including persistent data storage (ie a database, xml files, whatever;
the app won't care so long as the plugin implements the interface). The
issue is this: when the plugin retrieves data from storage to give to
the app, it is returning data which represents objects from the
application's data model. For example, the application might request the
plugin to retrieve the data for a particular Bicycle object from
storage, and the plugin might retrieve a bunch of data from a database,
eg a unique id (int), a String label, a few other ints, a few other
Strings etc. So the question is this: should the plugin return the "raw"
data (and leave it to the application to create a Bicycle object from
it), or should it create an object of type Bicycle from the raw data and
return that to the application? Returning the object itself *looks*
neater from the point of view of creating the interface for data storage
(ie request a Bicycle by its id, get a Bicycle object back), *but* doing
it this way requires that plugins be built against the application's
data types - a 3rd party plugin developer would be forced to compile
their plugin against the main application, which does not seem like good
design.
Any ideas or suggestions? I was contemplating separating out the
application's data model into its own small jar so that it could be
downloaded separately and linked against by anyone wanting to write a
plugin, which seems like a fair middle ground between requiring the
plugin to be built against the entire application and the application
receiving only "raw" data from the plugin which then has to be converted
into the appropriate object by the application.
Alternatively, is it better to insert an additional layer in between the
main part of the application and the data storage layer to marshall
between the raw data coming back from the data layer and the specific
data types that the application expects?
Thanks for any advice, and apologies for the long-winded post.
Shannon
Christian - 17 Mar 2007 23:06 GMT
Shannon Lloyd schrieb:
> Hi,
> I am writing an app which will permit plugins for various things,
[quoted text clipped - 29 lines]
> Thanks for any advice, and apologies for the long-winded post.
> Shannon

Why don't you also declare an interface IBycicle
and request that to be returned .. so you don't enforce a datatype ...
nor get raw data back .. forceing interfaces on them, well thats what
you are doing anyway with the definition on the plugin.. so why not one
more?

Christian


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.