Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Design Pattern for implementing plugins in your application? [closed]

Tags:

What is the standard way for allowing and implementing a plugin system for your application?

In my last application I made a simple interface for all plugins that they must implement. I then load all assemblies in the apps directory and toss out any that don't implement that interface.

One of the methods in the interface is a DoWork() method that periodically gets called on all loaded assemblies to perform any actions the plugins may have.

What is the "proper" way to do a plugin system? Do you just create an Interface for plugins? Should you periodically call a particular method in all plugins? Is there a more sophisticated way?


EDIT:

Thank you Matt Hamilton for the reference to the System.Addin namespace. This will most likely be the way I implement my plugins. However, I am still curious about plugin architecture in general and wouldn't mind some background on the best way they should be designed, implmemented.. how you should call on them once loaded, etc.

like image 575
mmcdole Avatar asked Oct 07 '08 03:10

mmcdole


People also ask

Which is a plugin architecture pattern?

A plug-in is a bundle that adds functionality to an application, called the host application, through some well-defined architecture for extensibility. This allows third-party developers to add functionality to an application without having access to the source code.

What are the design patterns used in Web applications?

4 Design Patterns You Should Know for Web Development: Observer, Singleton, Strategy, and Decorator.

What is design pattern and implementation?

Design patterns are programming language independent strategies for solving a common problem. That means a design pattern represents an idea, not a particular implementation. By using design patterns, you can make your code more flexible, reusable, and maintainable.

When should an adapter pattern be used?

The Adapter pattern allows otherwise incompatible classes to work together by converting the interface of one class into an interface expected by the clients. Socket wrenches provide an example of the Adapter.


2 Answers

Check out the System.AddIn namespace as per this response to a similar question.

like image 89
Matt Hamilton Avatar answered Jun 08 '23 07:06

Matt Hamilton


Glenn Block and Brad Abrams at Microsoft have recently released the Managed Extensibility Framework that provides a framework for dealing with exactly what you are talking about.

The documentation and download are available here.

Glenn's and Brad's blogs are also great resources for MEF.

like image 26
JeremiahClark Avatar answered Jun 08 '23 06:06

JeremiahClark