Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Advice on creating interface for plugins

Reply
Thread Tools

Advice on creating interface for plugins

 
 
Shannon Lloyd
Guest
Posts: n/a
 
      03-17-2007
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
 
Reply With Quote
 
 
 
 
Christian
Guest
Posts: n/a
 
      03-17-2007
Shannon Lloyd schrieb:
> 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


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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Advice on basic jedit plugins BillJosephson Java 0 11-28-2006 05:11 AM
PCI interface or USB interface David Wireless Networking 4 09-16-2004 01:01 PM
allow ssh only on outside interface, but telnet on inside interface of router no-one Cisco 0 07-28-2004 04:17 PM
PIX: how to allow 1 host from outside interface to access another host on the inside interface? jonnah Cisco 1 04-21-2004 02:26 PM
static nat between phisical interface and virtual interface on same ethernet Andrea Cisco 0 04-19-2004 09:37 AM



Advertisments