MEF ,Prism and the Surrounding Confusion!!

While reading up on Prism 4…the integrated Prism which ships in .NET 4.0, i  saw people still wondering on how MEF and Prism compare…are they the same…do they complement….etc etc..Having seen these questions almost 2 years back with Prism(then called the CAG) and MEF were just announced i was surprised the confusion still exists…

Here is how i explained it to myself…hopefully it helps you too!!

The main reason everyone seems to be confused it “they both help create extensible and modular applications”!!!

MEF is primarily an “extensibility” model…it helps you make “extensible” applications by allowing your application to “import” modules dynamically at runtime. For example all you may need to do is drop the dll of your module at a specific folder and it magically becomes a part of your application!!

So it “explicitly” provides “extensibility” because you are purposely extending your application by importing modules into it , and it “implicitly” provides modularity because your application is made up of modules!!!So the MAIN reason you would go for MEF is when you want a modular application with application extensions where the extensions can be added dynamically and at runtime..


Now for Prism..

Prism is a “guidance” on how to make client applications modular. It maintains modularity by keeping all the modules of the app loosely coupled(with no knowledge of each other). The GUI defines regions where the modules are loaded dynamically. The framework provides a publish-subscribe events model via an EventsAggregator which enables the modules to communicate with each other without any tight coupling..

So Prism “Explicitly” provides modularity and implicitly supports Extensibility as a side effect of good modularity:-)

Now with Prism 4.0 we can see examples of using Prism +MEF together which will be the ultimate combination of an extensible and modular application!!

Hope this clears your confusion…it definitely cleared mine!!


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>