Silverlight TV Episode 4: 3 Steps to MEF - Export, Import, Compose

Download this episode

Download Video

Description

John interviews Hamilton Verissimo, of Castle Windsor fame, about his latest work on the MEF team. Hamilton (aka MEF Man) discusses what MEF does and why you want to use MEF with your Silverlight applications. He dives right into the code samples and walks through examples of creating composable objects from scratch. He exported, imported, and composed parts with skill! Hamilton had such a great time the we decided to schedule a follow up series with the MEF team to cover more scenarios with MEF and Silverlight.

You can download the source code for Hamilton’s demo from this episode by clicking on this link.

Follow @SilverlightTV on Twitter for the latest updates.

Embed

Format

Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • User profile image
      ramteerathr

      Great vid John - your explanations clarified some of the MEF concepts. What I did not get a clear understanding of is where the actual mapping between interface and concrete classes took place. In something like Prism you have DI that does that mapping for you. For example how do I know that the send mail interface maps to the smtp send mail class and not another class that implements the same interface?

    • User profile image
      haveriss

      > For example how do I know that the send mail interface maps to the smtp send mail class and not another class that implements the same interface?

       

      Actually you don't. And that's the beauty of it. Unless you need an implementation of a contract that "expose some special capabilities", which you can do with metadata and I'll show on the next show.

    • User profile image
      figuerres

      possibly it was just me but i have to say that this show was not very good at explaining to me why i would want to learn more about MEF.

       

      I think Hamilton was possibly not really ready to explain it? or perhaps the time allowed was too short ?

      part of the problem may have been that he seemed to not be sure of what he was showing us? confused?

       

      *I THINK*  it may be a good thing but this demo just left me confused - does this do something or just create a bunch of [] words to add to classes ??

       

      sorry but we need a longer and more functional segment to really show "why i need this" and "what it does for my app".

       

    • User profile image
      jopapa

      Figuerres - Thank you for watching! It was a short segment by design to show the basic ways to use MEF. We already have a few more MEF shows planned to dive into deeper and more diverse scenarios to show where MEF shines. I've asked the MEF team to reply to your comment too so we can calrify some of the "why use MEF" points on your post.

       

      I think the future shows will help clarify things a bit more too, as the full story gets revealed. The next epsiode airs on Monday.

    • User profile image
      haveriss

      Figuerres, what I've shown is the basic of importing/exporting applied to Silverlight scenarios. It may be confusing if you are not buying into *why* MEF is great technology.

       

      The case in point is MEF is all about extensibility. With this goal it encourages a design that enables reuse and isolation. This way you can reuse your "parts" across projects and save time. By encouraging a design that depends more on aggregates we encourage the Composition over Inheritance design principle, which opens door to customizations through extension points.

       

      That said, there's no shortcut to understand the why. You need to feel the pain of your existing development model and see how MEF helps with that.

    • User profile image
      figuerres

      Haveriss:  perhaps you miss understand what i am saying.  I have been developing software for a while now. i have been thru the "component" thing a few times now with VB with COM with OLE and With .Net today.

      i was sying that this first into to MEF was just not clear and did not really explain to me what it does and why it's better than any other model of how to solve this problem. I am notsaying that MEF is no good or that I don't "Get it" I do "Get it" possibly as i watch more of the story i will get more of what the first segment was lacking.

    • User profile image
      koonuf

      I think that usually MEF demos don't explain how exactly are imports satisfied. Does MEF search all referenced assemblies for all the exports? When does this "scanning" actually happen (performance implications). Also, how does it stand out compared to "classic" DI frameworks?

    • User profile image
      gblock

      Hi Figuerres

       

      We tried to address this in the follow up video: http://channel9.msdn.com/shows/SilverlightTV/Silverlight-TV-7-When-and-Where-to-use-MEF/

       

      Let us know if it helps.

    • User profile image
      gblock

      @koonuf We scan catalogs which the default one in SL looks at all of the assemlies in the current xap.

       

      As far as how we compare to existing IoC containers, this post sheds some light on that: http://blogs.msdn.com/gblock/archive/2009/08/16/should-i-use-mef-for-my-general-ioc-needs.aspx

       

      Thanks

      Glenn

    • User profile image
      Pawel.G

      Every time he says "MEF" I think "meth", which makes it difficult to watch Tongue Out

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to send us feedback you can Contact Us.