When to use MEF

I tried Unity and MEF and plain old. And I'm a little confused when you need to use any of these "patterns". Why should I use MEF or Unity if using the new one is easier and suits my needs.

In other words, what is needed to justify using MEF or Unity?

+2


a source to share


1 answer


MEF allows you to isolate subsystems in an application. This isolation is useful if you need to change subsystem implementations frequently, or even at runtime. MEF takes care of the details of loading subsystems and connecting all vendors to their respective consumers. This is a giant leap forward towards the ideal of building an application by bringing together a collection of standalone modules that know nothing about each other.

Much of the code in a traditional app is for simple glueing of things - glue code. MEF significantly reduces the need for glue.



If you're just creating an object to open a file or show a dialog, that's not what MEF is for. If you want to write code that uses the xyz generic service, but don't want to hard-code a dependency on a vendor or vendor b implementation, that might be a MEF candidate.

+4


a source







All Articles