MEF 与 PRISM。有什么区别?未来会支持什么?
我想要创建的是一个 Silverlight 应用程序,其中包含一些选项卡/模块,它们都是单独的 DLL。
我看到 PRISM 有 Shell/模块概念,似乎是针对做 UI 的,我找到了一个很好的演示(展示了如何搜索 digg/twitter)。
但听起来 MEF 将包含在 VS2010 中,所以我想选择这个选项。
任何人都可以以某种方式清楚地解释这些差异吗? (我不是高级程序员)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
MEF 和 Prism 有两个截然不同的目标。
Prism 基本上是设计复合应用程序的指南 - 在其中您有一个 shell 和动态分配和集成的“区域”。它包含一个用于注入的 IoC 容器 (Unity)。
MEF 是一个依赖注入框架 - 它的主要目标是在应用程序运行时“填充”依赖关系。在这方面,它实现了与 Unity 在 Prism 中实现的目标相同的目标(事实上,您可以很容易地重新设计 Prism 以使用 MEF 而不是 Unity)。
Prism 在某些方面涵盖了更广泛的范围,但实际上也仅限于 GUI 应用程序。 MEF 只是做一件事(Dep. Injection),但旨在实现更通用的目的,适用于任何类型的应用程序。
至于这些产品的生命周期,这里没有答案,但这就是它们的开发方式:
Prism 是由模式和实践团队开发的。我们的目标不一定是制作软件,而是提供指导。因此,他们更新(尽管不太频繁)Prism 库和示例,但 Prism 并不是 Microsoft 提供的框架的核心部分。它实际上是一个第三方图书馆(尽管 MS 为其提供了大量资金,但大多数 P&P 人员都不是 MS FTE)。
从博客文章来看,MEF 听起来像是计划集成到框架中,并直接在 MS 项目内部使用。因此,它直接从 Microsoft 得到大力开发,并在他们的产品中使用。
我个人已经阅读了 Prism 文档(并且拥有这本书),并且已经浏览了示例。了解如何分解应用程序非常有帮助,但它实际上不仅仅是一个完整的、可用的框架。这些示例非常擅长完成其设计目的 - 教育架构师如何设计复合应用程序。
如果您的目标只是在 silverlight 应用程序中保持关注点的清晰分离,那么我会更多地关注学习 MVVM 而不是仅仅使用 Prism。
如果您想使用 MEF,还有其他不错的选择。例如,WPF 应用程序框架是一个基于 MEF 构建的完整 MVVM 框架,而且相当不错。
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.
基本上,MEF 是一个通用的可扩展性框架:
而 Prism 主要用于构建 GUI:
Basically, MEF is a general-purpose extensibility framework:
whereas Prism is mostly for building GUIs:
嗯,不完全一样。 MEF更关注编译时未知的扩展,而IOC容器通常关注编译时已知的依赖项。 这个问题的最佳答案很好地解释了这些差异。
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.
是的。查看这两篇文章以了解更多信息:
http://blogs.msdn.com/gblock/archive/2009/12/02/mef-and-prism-to-be-or-not-to-be.aspx
http://blogs.msdn.com/ dphill/archive/2009/12/09/prism-and-mef.aspx
Yes. Check these two posts for more:
http://blogs.msdn.com/gblock/archive/2009/12/02/mef-and-prism-to-be-or-not-to-be.aspx
http://blogs.msdn.com/dphill/archive/2009/12/09/prism-and-mef.aspx