8
What the heck is MEF? And why should I care? Jason Offutt Software Engineer Central Christian Church Email: [email protected] Twitter: @JasonOffutt #RefreshCache

Rc2010 mef

Embed Size (px)

DESCRIPTION

RefreshCache 2010 presentation on Microsoft's Managed Extensibility Framework and how to apply it to Arena ChMS.

Citation preview

Page 1: Rc2010 mef

What the heck is MEF?

And why should I care?Jason Offutt

Software EngineerCentral Christian Church

Email: [email protected]: @JasonOffutt

#RefreshCache

Page 2: Rc2010 mef

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

Page 3: Rc2010 mef

And I should care because?

• It allows us to make our code more like Legos Modular & pluggable Encapsulated functionality Not dependent on other

components

Page 4: Rc2010 mef

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)

Page 5: Rc2010 mef

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

Page 6: Rc2010 mef

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.

Page 7: Rc2010 mef

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

Page 8: Rc2010 mef

Less talking, more code!