Why MEF?

A fellow software engineer at work asked me this very question today and my unedited response is below (except I remove my company name):

Oh you bet I have an opinion! (not that anyone listens to me) But I will warn you before I write it that I just woke up and I’m still recovering from being in and out of the hospital that resulted in two emergency surgeries, so my attitude is going to come through so I apologize in advance.

So we have been able to do dependency injection in .NET for a while but it’s never been that easy so most people did not use it. Now with .NET 4, MEF makes it much easier and I highly recommend it for any program that could be extensible in the future (which I think would include most of the apps at our company). Most people are confused on where to apply MEF. It works great for UI and business logic and should be used for both. Did you know that is exactly how VS 2010 is designed? It’s just a bunch of MEF extensions.

Prism on the other hand if similar but is more of an entire application framework and is much more on the other end of complexity. It is very powerful but takes a long time to learn and to architect correctly. I believe it is the right choice for very large enterprise systems, but the correct time needs to be given to architect it correctly otherwise like most frameworks it’s just going to fall down and be counterproductive. As we all know at our company we are usually not given this time, but if we are this could be a viable option too and maybe better in the long run.

Also another consideration is that the concepts that both these frameworks are alien to most programmers at our company (heck many can’t even write LINQ or Lambda statements). So time will have to be added to the schedule for proper training. This is a requirement!!!!

One another note, I have had the experts on MEF and Prism speak at the group I run, the San Diego .NET Developers Group, which NO ONE at our company attends!!! (they both are my longtime friends and this is why I know so much about this because I have talked one on one with them about these frameworks) It saddens me that we have so many developers at our company and they can’t spare three hours a month to learn about these new technologies (my attitude showing).

I would value your feedback! Use the comment box below.