Advice on creating interface for plugins

Discussion in 'Java' started by Shannon Lloyd, Mar 17, 2007.

  1. 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
    Shannon Lloyd, Mar 17, 2007
    #1
    1. Advertising

  2. Shannon Lloyd

    Christian Guest

    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
    Christian, Mar 17, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Asun Friere
    Replies:
    1
    Views:
    489
    Paul Boddie
    Aug 27, 2003
  2. Peter Hansen
    Replies:
    23
    Views:
    855
    Anton Vredegoor
    Sep 5, 2003
  3. Gerrit Holl
    Replies:
    16
    Views:
    606
    Tom Plunket
    Aug 29, 2003
  4. Asun Friere
    Replies:
    0
    Views:
    470
    Asun Friere
    Aug 28, 2003
  5. BillJosephson

    Advice on basic jedit plugins

    BillJosephson, Nov 28, 2006, in forum: Java
    Replies:
    0
    Views:
    265
    BillJosephson
    Nov 28, 2006
Loading...

Share This Page