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 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?

share|improve this question

closed as not a real question by Robert Harvey, Telastyn, gnat, Walter, Yusubov Nov 6 '12 at 1:25

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

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". –  user61852 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
add comment

2 Answers

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.

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

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:

http://www.infoq.com/presentations/Making-Roles-Explicit-Udi-Dahan

share|improve this answer
add comment

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