When we are developing an application, if we thought about the cost and the time, mainly it will be 20% for the original software development and the rest 80% will be for the software maintenance. The thing is later we will have to add new modules to original application which means we will have to extend the original application. When extending an application, as developers we know basically two things. That is KNOWN part and UNKNOWN part. The known part is since we know how we developed the application, we have the ability to change the source code. The unknown part is, if we want to plug our application with a third party application, we know nothing about their implementation. Because when we are developing, it wasn't a requirement.
So the best practice is to compose an application from various of pieces. As one of the principles in Object Oriented Design says, which is Open/Closed Principle, software entities should be open for extension but closed for modification. That is we should be able to extend the behavior of classes etc without modifying the source code. Classes' should have one reason to change. That is if one of the dependencies change like recently introduced bug etc.
Managed Extensibility Framework
Managed Extensibility Framework is designed to help developers to extend the application without changing the original source code. The core concept behind MEF is, MEF is aiming on composing an application which is dynamically compiled rather than statically compiled. To bring all these nice features MEF stands upon few concepts.
- An application is built of Parts. This is the core of MEF. You can think of it like building blocks of MEF.
- Once you have implemented a Part, you can Export it. By exporting you are declaring "This part is available for the rest of the system. If you want it, you can consume it.".
- Now think of another Part. He is saying "I want this part for me to be perfect. I want to consume it.". When he is using your part, that is importing.
- To satisfy their needs we take all the Exports, we take all the Imports, we match them with each other and we are putting them with each other. How MEF really does is, in MEF there is a concept called Catalogs. Catalogs discovered the Parts and provide the Parts. And finally we have the Container which is a match maker. It is responsible for matching all the Exports with Imports.
For more information on MEF visit MSDN,
Hope you all got some basic understanding in Managed Extensibility Framework. Please feel free to post your valuable feedback.