Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm starting a hobby project and I'm in the middle of designing its architecture. I would like to make my program plugin-based (never done anything like that before), to make it extensible. Now I'm trying to grasp how such an architecture is created conceptually.

Now, this wikipedia article about Plugins says that the host application is supposed to provide a protocol service (among other things) to establish how data is exchanged with the plugin.

I don't really understand this tidbit, what does that mean? What kind of data actually needs to be exchanged?

EDIT: Just to be clear, I'm not looking for implementation specifics, but for a clear explanation of the mechanism, that the wikipedia article presents. As it stands now, I have no idea what the purpose of a protocol in a plugin-based application is.

I figured, the plugin could just fetch relevant data from outside the application on its own and present it to the user, without directly involving the application. What would be the purpose of establishing a protocol for data exchange?

It's a desktop application, which will be written mainly in Java, thus object-oriented. The application at its core mainly provides an interface for plugins to register itself in the application and a plugin-manager, which interacts with the plugin.

share|improve this question
    
Far too vague. What kind of application, web, desktop, embedded. What kind of development language, imperative, functional? etc –  Raynos Dec 4 '11 at 2:07
    
I want to understand the meaning of having a protocol for data exchange, not how I need to implement that. But for clarification I have edited my question. –  Miroslav Cetojevic Dec 4 '11 at 7:24
    
Fetching the Data from outside is (most likely) a very bad Idea, you will be duplicating code and get out of sync with the host Application. –  Fabio Fracassi Dec 4 '11 at 10:04
    
The Interface for the Plugins to register themselfs is already an example of the protocol you are searching for. If your Application consists only out of plugins, parts of the protocol move to between the plugins instead of between plugin and host –  Fabio Fracassi Dec 4 '11 at 10:06
    
Hm, maybe I'm beginning to understand the protocol idea. But why is the protocol moved to between plugins if the application only consists of plugins? The application has a set of core services that allows the plugin to interact with the application, would that not mean, the protocol only allows for interaction between plugin and application? –  Miroslav Cetojevic Dec 4 '11 at 10:24
add comment

1 Answer

up vote 1 down vote accepted

In my view, plugins are sharing the same address space (& process) as the receiving application and involve dynamic linking.

In Linux parlance, I think that a plugin is a dynamically loaded shared object which is dlopen-ed by the application.

Then the application has to define what dlsym-ed symbols are expected by the application in the plugin, and how they interact with (i.e. how they are called by) the application.

A concrete exemple is given by Gcc plugins (I'm working on MELT, a high-level domain specific language to extend GCC, implemented as a [meta-] plugin); as the document explains, it define some set of conventions that you would call a "protocol service"

Added:

So the plugin protocol is the set of conventions (and associated API and names) defining how the plugin is installed, and which plugin's functions (and names) are expected, in what order and conditions they are invoked by the application, and which application data and API the plugin can access (and modify).

share|improve this answer
    
By plugin protocol do you mean the plugin defining how it interacts with the application or the other way around, the application defining how it interacts with the plugin? –  Miroslav Cetojevic Dec 4 '11 at 10:22
    
The application exists before the plugin, so it is more the application which defines how the plugin should interact. However, defining such a protocol is not easy, so you should co-design your application and a first non-trivial plugin. –  Basile Starynkevitch Dec 4 '11 at 11:35
    
Yeah, figures. Thanks for your answer. –  Miroslav Cetojevic Dec 4 '11 at 13:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.