Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to marshall data in/out of the plug-ins?

I am building my workstation Agent application using MEF and EntityFramework 4.

The application is a simple agent that runs on a computer with a plug-in architecture (and many plugins in the form of .dll files).

Each plug-in will query their own plugin-specific table. The master program (or agent) needs to pass information to the plug-in, and receive information from the plug-in.

The plug-ins will use the Entity Framework 4.1 to retrieve the data, so it will already have the data formatted as objects (perhaps heavy objects since they are tied to the EF context). Also, the data I am pulling back from the database is a series of joins, so the data doesn't match any of the POCO identities/classes I had already created.

What is the best way to marshall data in/out of the plug-ins? Taking into consideration that I am using MEF to tie the pieces together, and that I already have objects for the data in the plug-ins. Should I create a new POCO and move the Entity Data into it, then shuffle arrays? Should I create a List? I am not only interested on what can be done, but what are best practices!

like image 553
s0ftimage Avatar asked May 03 '11 21:05

s0ftimage


1 Answers

This is a good article on Data Transfer Objects. It touches on the points you are bringing up here with the POCO objects. Since your building an application with the explicit intent of further expansion and customization, I think that the POCO objects are the way to go. Otherwise, any further components will require dependencies on EF which may be burdensome for the plugin developers. With the POCO/DTO objects, you will have a lot more control over what gets sent and what structures it gets sent in.

The plugins should either implement a (virtual?) base class or an interface. I would probably choose interface because - again - it will be easier for plugin developers to add an interface to their code than a base class.

Really, I'm not saying anything new that you, Omar and Adventure haven't already said. Basically I am saying that I think you've already got a good handle on it :)

like image 158
Jeff Avatar answered Nov 16 '22 00:11

Jeff