MEF: a replacement for PRISM?
Asked Answered
L

4

9

To what extent, if any, is MEF a replacement for PRISM?

Lewislewisite answered 24/8, 2009 at 20:51 Comment(0)
H
8

Edit: Do not read this answer. It is embarrassingly wrong. I am fail. Read Glenn Block's below.

It's not obvious, but this is the same question: Managed Extensibility Framework (MEF) vs. Composite UI Application Block (CAB)

Consensus in the duplicate post is that MEF and Prism provide the same basic set of functionality in different ways, except that Prism provides the Event Aggregator, which is a pub-sub means of communication between application components. You can use this with MEF, however. It's pretty much up to preference, really.

Hoary answered 24/8, 2009 at 21:30 Comment(3)
Ugh... I know it was from a year ago and I've learned a lot, but this answer is really wrong. Glenn Block's post is more precise. You can see this most prominently in the fact that Prism V4 has an option to use MEF for various forms of IoC and composition. I can't delete or even downvote my own post.Hoary
It's weird reading something and saying "who is this dumbass?... oh"Hoary
+1 for pure honesty. Although your answer is not the "most correct", it gives insight in contrast to Glenn's answer. The lines of responsibility/functionality between MEF/Prism/Unity/MAF are pretty fuzzy (and you don't deserve a downvote either).Sedda
F
37

Today I would say Prism and MEF complement each other. Just as Prism and Unity. Prism introduces a set of specific services like RegionManager, DelegateCommand, and EventAggregator which aid in building composite apps. MEF on the other hand is a more general composition mechanism for extensibility of applications and frameworks whether they are composites or no. The key distinguisher about MEF is it's discoverability which means that it can go out and discover all the available parts dynamically.

You might be interested in checking out the MEF contrib project (mefcontrib.codeplex.com) which contains an integration layer for Unity and MEF. With that extension, Unity manages MEF behind the scenes, so you are not contending with two contianers. The advantage is it allows you to use Unity for general Pocos, and MEF for discovery of extensions. Thus as Prism is currently built on Unity, you can use it to leverage MEF. To use the contrib project, you'll have to make some slight changes to your Unity Bootstrapper, but it should be fairly trivial.

There is definitely some overlap. The place where it's the most prominent is with regard to modules. Prism uses an IModule as a means of discovery. In MEF, any component can be a part and can be dynamically discovered. This means with MEF you have modularity from top to bottom, wheras with Prism, modules are more granular units. Composite applications is definitely an area we are conerned with on the MEF time. Over time it is quite likely you will see more and more support for building those types of apps within MEF itself. We're working with p&p to ensure that as that happens, there is a smooth transition.

Flashcube answered 12/9, 2009 at 20:34 Comment(1)
Keep in mind though, that MEF support in Prism is coming to an end: “MEF is supported with WPF for compatibility with previous versions. It will not be added to Windows 10 UWP or Xamarin Forms.”Guayule
H
8

Edit: Do not read this answer. It is embarrassingly wrong. I am fail. Read Glenn Block's below.

It's not obvious, but this is the same question: Managed Extensibility Framework (MEF) vs. Composite UI Application Block (CAB)

Consensus in the duplicate post is that MEF and Prism provide the same basic set of functionality in different ways, except that Prism provides the Event Aggregator, which is a pub-sub means of communication between application components. You can use this with MEF, however. It's pretty much up to preference, really.

Hoary answered 24/8, 2009 at 21:30 Comment(3)
Ugh... I know it was from a year ago and I've learned a lot, but this answer is really wrong. Glenn Block's post is more precise. You can see this most prominently in the fact that Prism V4 has an option to use MEF for various forms of IoC and composition. I can't delete or even downvote my own post.Hoary
It's weird reading something and saying "who is this dumbass?... oh"Hoary
+1 for pure honesty. Although your answer is not the "most correct", it gives insight in contrast to Glenn's answer. The lines of responsibility/functionality between MEF/Prism/Unity/MAF are pretty fuzzy (and you don't deserve a downvote either).Sedda
G
2

Take a look at this Sparkling Client podcast on MEF and Prism.

Goldy answered 24/8, 2009 at 20:58 Comment(0)
M
0

MEF will never replace prism

MEF is a dependency injection manager.its not a dependency injection container.
MEF provides ability to assign exports and imports delclaritively using attributes.

Prism with MEF gives you ability to ability to auto discover dlls and ability to add and remove plugins by adding or deleting dlls. Where as prism framework gives event aggregator, region manager, service locator.

You can use prism without MEF. There are various other options like ninject, unity and other DI containers.

You can use MEF with prism for building plugin based extensible applications.

Misspell answered 1/9, 2016 at 2:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.