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?
5
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.
1
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