I am working on application, details of which I cannot discuss here. We have core framework and the rest is designed as plug in. In the core framework we have a domain object. This domain object is updated by the plugins. I have defined an interface in which I have function as

DomainObject doProcessing(DomainObject object)

My intention here is I pass the domain object, the plug in will update it and return it. This updated object is then passed again to different plugin to be updated.

I am not sure if this is a good approach. I don't like passing the DomainObject to plugin. Is there a better way I can achieve this? Should I just request data from plugin and update the domain object myself?

  • 3
    This question is incredibly vague to the point that it's hard to formulate an answer. The answer to "What should I do?" is almost entirely based on the answer to "What are you trying to do?" – Daenyth Nov 5 '12 at 15:57
  • I am trying to come up with a better design for the problem I stated. I don't think passing the domainObject to the plugin is a good idea. It expects the plugin to be a good citizen. This is a dependency I wish to remove. – Varun Naik Nov 5 '12 at 16:01
  • It would be better if your plug-ins just implemented basic processing functionality and didn't know much about the (hopefully simple) domain objects they'd be passed; assembling processing results from the plugins should be done in the core app. That way, you can change the implementation of the core without having to worry about breaking the plug-ins. – paul Nov 5 '12 at 16:27
  • Plugins should be signed and trusted. That way you can pass DomainObject without fear. Plugins in Photoshop for example are allowed to modify the image which in the case of Photoshop are the "domain objects". – Tulains Córdova Nov 5 '12 at 16:35
  • +1, The domain objects are not simple. It seems a better idea, that core expects the results and update the objects. – Varun Naik Nov 5 '12 at 16:36

You could use Data Transfer Objects that get filled by the plugins. Or pass around (deep) copies of your domain objects. And then let your core implementation verify the changes to those objects before applying them to the real instances.

| improve this answer | |
  • 1
    +1, I cannot vote up, but thanks for the answer. – Varun Naik Nov 5 '12 at 16:28

This sounds a bit more like a pipeline / pipes and filters approach than a plug-in architecture.

There is nothing wrong with the approach. You need to be careful not to go for a too generic approach.

You may want to have a look at Udi Dahan's excellent presentation around making roles explicit:


| improve this answer | |

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