18

What I want to create is a Silverlight app with a few tabs/modules that will all be separate DLLs.

I see PRISM has the Shell/Module concepts that seem directed towards doing UI and I find a nice demo (showing how to search digg/twitter).

But it sounds like MEF will be included in VS2010 so I would like to go with that option.

Can anyone somehow clearly explain the differences? (I am not a advanced programmer)

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
punkouter
  • 5,170
  • 15
  • 71
  • 116

4 Answers4

24

MEF and Prism serve two very distinct goals.

Prism is basically guidance for designing composite applications - where you have a shell and "regions" that are dynamically assigned, and integrated. It includes an IoC container (Unity) that it uses for it's injection.

MEF is a dependency injection framework - it's main goal is to "fill in" depedencies at runtime for an application. In this respect, it's filling the same goal as Unity does within Prism (and, in fact, you could pretty easily rework Prism to use MEF instead of Unity).

Prism fills a broader scope, in some respects, but is also really limited to GUI applications. MEF is just doing one thing (Dep. Injection), but geared to be more general purpose, for any type of application.


As for the lifetime of these products -there is no answer here, but this is kind of how they're being developed:

Prism was developed by the Patterns and Practices team. The goal isn't to necessarily make software, but to provide guidance. As such, they update (although somewhat infrequently) the Prism library and sample, but Prism isn't a core part of the framework shipped by Microsoft. It's really a third party library (even though MS funds a lot of it, most of the P&P people aren't MS FTE).

MEF, from the blog posts, sounds like it is planned to be integrated into the framework, and be used directly inside of MS projects. As such, it's getting heavy development, directly from Microsoft, and being used in their products.

I, personally, have read through the Prism documentation (and have the book), and have gone through the samples. It is very helpful to understand how to break apart an application, but it really is guidance more than a complete, usable framework. The samples are very good at doing what they're designed to do - educate an architect in how to design a composite application.

If your goal is to just keep a clean separation of concerns in a silverlight application, I'd focus more on learning MVVM than necessarily just using Prism.

If you want to use MEF, there are other good options. For example, the WPF Application Framework is an entire MVVM framework built on top of using MEF, and fairly nice.

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373
  • 1
    Mixing concerns here a little... Prism's core services have little to do with MVVM... the guidance package pushes MVVM/MVP, but Prism "The Bits" can't be summed up as an MVVM framework. – Anderson Imes Oct 20 '09 at 20:57
  • Yes, I agree. I was suggesting that looking at MVVM might be a better focus than necessarily looking at Prism, given the OP's desire to build an app "broken into pieces". I was not trying to suggest that Prism was an MVVM framework. – Reed Copsey Oct 20 '09 at 21:33
  • Given your rep around here I thought as much, it just sounded like that. Your edit cleared things up nicely. :) – Anderson Imes Oct 21 '09 at 14:19
  • I want to learn both MVVM and Prism.. And understand the basics of the whole DI stuff since I am not a advanced programmer. So it seems to me our next small biz app for our intrnet I will use Prism. It should be educational. – punkouter Oct 21 '09 at 16:32
6

Basically, MEF is a general-purpose extensibility framework:

If you are building extensible applications, extensible frameworks and application extensions, then MEF is for you.

whereas Prism is mostly for building GUIs:

The Composite Client Application Guidance is designed to help you more easily build modular Windows Presentation Foundation (WPF) and Silverlight client applications.

Anton Gogolev
  • 113,561
  • 39
  • 200
  • 288
6

So MEF and Unity are basically the same...

Well, not exactly. MEF is more focused on extensions which aren't known at compile time, while IOC containers generally focus on dependencies which are known at compile time. The top answer to this question gives a good explanation of the differences.

Community
  • 1
  • 1
Daniel Plaisted
  • 16,674
  • 4
  • 44
  • 56
  • 2
    And in Unity, you provide which extensions you want to run sometime during execution. With MEF, in contrast, the extensions are not necessarily provided by your application, but are discoverable, and when available, can be automatically included. – Doug Mar 18 '11 at 22:26