Upload
jasonoffutt
View
238
Download
4
Embed Size (px)
DESCRIPTION
RefreshCache 2010 presentation on Microsoft's Managed Extensibility Framework and how to apply it to Arena ChMS.
Citation preview
What the heck is MEF?
And why should I care?Jason Offutt
Software EngineerCentral Christian Church
Email: [email protected]: @JasonOffutt
#RefreshCache
Managed Extensibility Framework
• Originally an Open Source project started by Microsoft developers (mef.codeplex.com)
• Now comes baked into .NET 4.0 Included in System.ComponentModel.Composition
And I should care because?
• It allows us to make our code more like Legos Modular & pluggable Encapsulated functionality Not dependent on other
components
So what can MEF do?
• Act as an IoC container• Manage dependency injection without tons of
configuration• Plays match-maker for your code
“You use MEF to manage a set of unknown things. You use IoC containers to mange a set of known things.” – Glenn Block (MEF project manager)
How can Arena benefit from MEF?
• MEF can simplify the way we do dependency injection Less code to maintain! No need for configuration in web.config or Arena Org Settings and
Lookups MEF will dynamically load the correct object based on the
contract/interface declared at runtime Allows for lazy-loading objects to delay expensive database calls
How can Arena benefit from MEF?
• Allows us to keep our components very loosely coupled
• Makes it easier to write testable code Less energy required to engineer our own “seams” for unit testing. If
you need a “fake” object, just use MEF to import it into your unit tests.
When can we use it?
• It’s baked right into .NET 4.0 When Arena supports .NET 4.0, it can be used
anywhere
• If you’re impatient, you can download the binaries for .NET 3.5 from mef.codeplex.com
Less talking, more code!