How to design extensible software (plugin architec

2019-01-09 21:54发布

I need some resources that talk about how to design your software to be extensible, i.e. so that other people can write add-ons/plug-ins that adds functionality to it.

What do you recommend? Any books out there that discuss the subject?
I would prefer something that's short and to the point; a bit of theory and a bunch of concrete examples.

I'm not targeting a specific language, I want to be able to understand the core idea so that I can implement it in any language.

And for the same reason, I prefer not to do it using a framework that someone else built (unless the framework is not very high-level, i.e. doesn't hide too much), at the moment I only want to educate myself on the subject and experiment with various ways to implement it. Plus, a framework usually assumes user's knowledge about the subject.

UPDATE

I'm not asking about OOP or allowing my classes to be inherited. I'm talking about designing an application that will be deployed on a system, such that it can be extended by third-party add-ons AFTER its been deployed.

For example, Notepad++ has a plug-in architecture where you can place a .dll file in the plugins folder, and it adds functionality to the application that wasn't there, such as color-picking, or snippet insertion, or many other things (a wide range of functionality).

13条回答
别忘想泡老子
2楼-- · 2019-01-09 22:17

Of course there is the famous Open Closed Principle - http://en.wikipedia.org/wiki/Open/closed_principle

查看更多
萌系小妹纸
3楼-- · 2019-01-09 22:24

Checkout "CAB" - Microsoft's Composition Application Building blocks Framework. I think they've got a "web version" of that too...

查看更多
Evening l夕情丶
4楼-- · 2019-01-09 22:25

OSGI is a good practical example of a technical framework allowing to do what you are after.

The theory is here.

The (free!) book is there.

Extensibility and the ability to write plugin must deal with service lifecycle

  • adding / removing service/plugin on the spot
  • managing dependencies between services
  • managing states of services (declared, installed, started, stopped,...)

What is OSGI for ?

One of the main functions of a module is as a unit of deployment… something that we can either build or download and install to extend the functionality of our application.

You will find a good introduction here, on the central notion of service (which is related to your question, and which explain some problems around services, key component for extensibility).

Extract:

Why are services then so important if so many applications can be built without them? Well, services are the best known way to decouple software components from each other.

One of the most important aspects of services is that they significantly minimize class loading problems because they work with instances of objects, not with class names. Instances that are created by the provider, not the consumer. The reduction of the complexity is quite surprising

Not only do services minimize configuration, they also significantly reduce the number of shared packages.

查看更多
淡お忘
5楼-- · 2019-01-09 22:28

Since I dont have enough rep points to leave a comment, I am posting this as an answer. SharpDevelop is an IDE for developing applications in C#/VB.NET/Boo. It has a pretty impressive architecture that allows itself to be extended in a number of ways - right from new menu items to development support for whole new languages.

It uses a bit of XML configuration to act as a glue layer between a core of the IDE and the plugin implementation. It handles locating, loading and versioning of plugins out of the box. Deploying new plugins is matter of simply copying in the new xml configuration file and the required assemblies (DLLs) and restarting the application. You can read more on this in the book "Dissecting a csharp application" by the original author(s) - Christian Holm, Mike Krüger, Bernhard Spuida of the application from here. The book doesnt seem to be available on that site, but i found a copy that might still be around here

Also found a related question here

查看更多
趁早两清
6楼-- · 2019-01-09 22:30

I have just started to develop a smart client application. These are two options I am considering.

Using Microsoft's System.AddIn namespace. Looks very promising, however it may be a little complex for our end solution.

Or the Smart Client - Composite UI Application Block from Microsoft

Recently, i have looked at taking components both the Composite UI Application Block and the System.AddIn namespace to build my own. Since source code is available for the CAB it is easy to extend. I think our end solution will be a light weight version of the CAB, definatly using the Unity Application Block

查看更多
女痞
7楼-- · 2019-01-09 22:36

The article Writing Plugin-Based Applications clearly explains the responsibilities of the various parts of the architecture using a very simple example; source code is provided (VB.Net). I found it very helpful in understanding the basic concepts.

查看更多
登录 后发表回答