How are you using the Managed Extensibility Framework

frameworksmefnet

I have been working with MEF for about 2 weeks. I started thinking about what MEF is for, researching to find out how to use MEF, and finally implementing a Host with 3 modules. The contracts are proving to be easy to grasp and the modules are easily managed.

Although MEF has a very practical use, I am wondering to what extent? I mean, is everyone going to be rewriting existing applications for extensibility?

Yes, that sounds, and is insanely impractical. Rhetorically speaking:

  • how is MEF affecting the current
    trends in programming?

  • have you begun looking for
    opportunities to use MEF?

  • have you begun planning a major
    re-write of an existing app that may
    benefit from extensibility?

That said, my questions are:
how do I know when I should plan a new project with extensibility?
how will I know if an existing project needs to be re-written for extensibility?

Is anyone using MEF?

Best Answer

Is anyone using MEF?

I'm working on a Silverlight project using the MVVM pattern. We started by just wiring all of the VMs together as necessary through interfaces and manual dependency injection (either constructor or property injection depending on the need). It began to get painful, and we started using MEF as basically a dependency injection framework to export certain services that are used across view models, and import them into the view models that need them. Works perfectly and with very little code.

Yes, there are some purists out there that will say MEF is not intended for dependency injection and a real dependency injection framework will do much better. However, MEF is baked right into .NET which is a big plus, and it was enough to meet our needs.

how do I know when I should plan a new project with extensibility? how will I know if an existing project needs to be re-written for extensibility?

IMO, you should always separate concerns appropriately and use interfaces to allow for different modules to change indepently. If you do this right, then when you find a need for extensibility, MEF should be easy to add in. But I wouldn't start a project that had no extensibility requirements and put MEF in just in case. I would wait for there to be a need. For existing projects, if a need arises, I would evaluate the effort of rewiring the project to use MEF versus alternative solutions versus not doing anything, and see which wins.

Related Topic