How to develop extensible software (plugin architecture)?

I need resources that talk about how to develop your extension software, i.e. so that other people can write add-ons / plugins that add functionality to it.

What do you recommend? Any books that discuss the topic? I would prefer something short and precise; a bit of theory and a bunch of concrete examples.

I am not tuned to a specific language, I want to understand the basic idea so that I can implement it in any language.

And for the same reason, I prefer not to do this, using the framework that someone created (if the structure is not very high-level, i.e. does not hide too much), at the moment I only want to train myself on this issue and experiment with various ways to implement it. In addition, the structure usually involves the user's knowledge of the subject.

UPDATE

I do not ask about OOP or do not allow my classes to be inherited. I'm talking about developing an application that will be deployed to the system so that it can be expanded with third-party add-ons AFTER deployment.

For example, Notepad ++ has a plug-in architecture in which you can put a DLL file in the plugins folder and adds functionality for an application that was not there, for example, to select a color or insert a fragment or much more (wide range of functions).

+61
language-agnostic plugins resources extensibility
Nov 27 '08 at 8:19
source share
13 answers

OSGI is a good practical example of a technical structure that allows you to do what you are after.

Theory (free!) Book is .

Extensibility and the ability to write a plugin must deal with the service life cycle

  • add / remove service / plugin in place
  • cross-service dependency management
  • service state management (advertised, installed, running, stopped, ...)

What is OSGI for?

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

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

Extract:

Why are services so important if so many applications can be built without them? Well, services are the best known way to separate 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 class names. Instances created by the supplier, not the consumer. The decrease in complexity is quite surprising.

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

+11
Nov 27 '08 at 8:24
source share

You are trying to achieve two competing goals:

  • Your software components need to be exposed a lot , so you can reuse them
  • Your software components should be very low , so you can reuse them

Explanation: To encourage code reuse, you must be able to extend existing classes and call their methods. This is not possible if the methods are declared "private" and the classes are "final" (and cannot be extended). Therefore, to achieve this goal, everything must be publicly available and accessible. No personal data or methods.

When you release the second version of your software, you will find that many of the ideas in version 1 were simply wrong. You need to change many interfaces or your code, method names, delete methods, break the API. If you do, many people will turn their backs. Therefore, in order to be able to develop your software, the components should not reveal anything that is not absolutely necessary - due to the reuse of the code.

Example: I wanted to observe the position of the cursor (carriage) in SWT StyledText. The carriages should not expand. If you do this, you will find that the code contains checks such as "this class in the org.eclipse.swt package", and many methods are private and final, and many more. I had to copy about 28 classes from SWT to my project in order to implement this function, because everything is locked.

SWT is a good structure to use and hell for expansion.

+4
Nov 27 '08 at 9:27
source share

Add SOLID principles to your application.

1. Single responsibility principle: A class should have only one responsibility (i.e. only one potential change in the software specification should affect the class specification

Principle 2.Open/closed: Software objects ... must be open for expansion, but closed for modification

3. The principle of Liskov substitution: Objects in the program must be replaced by instances of their subtypes without changing the correctness of this program

4. The principle of separation of segregation: Many client interfaces are better than one universal interface

5. The principle of dependency inversion:. Abstractions must be considered. Not dependent on nodules

Stackoverflow related questions:

Example of the principle of shared responsibility

Is the Open / Closed Principle Good?

What is the Liskov replacement principle?

The principle of separation of circuits - a program for the interface

What is the dependency inversion principle and why is it important?

+4
Feb 13 '16 at 13:17
source share

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

+3
Nov 27 '08 at 8:52
source share

Well, it depends on the language.

  • In C / C ++, I am sure that there is a loadlibrary function that allows you to open the library at runtime and call its exported functions. This is usually done in C / C ++.
  • .NET has Reflection, which offers similar (but wider) loadlibrary functions. There are also entire libraries built on Reflection, such as the Managed Extension Framework, or Mono.Addins, which already does most of the hard work for you.
  • There is also Reflection in Java. And there is JPF (Java Plugin Framework), which is used in materials such as Eclipse IIRC.

Depending on what language you use, I might recommend some textbooks / books. I hope this was helpful.

+2
Jan 25 '10 at 21:15
source share

The article Writing plugin-based applications clearly explains the responsibility of various parts of the architecture using a very simple example; source code provided (VB.Net). I found this very helpful in understanding the basic concepts.

+1
Jan 25 '10 at 21:10
source share

Checkout "CAB" - Microsoft Composition Application Building Block Framework. I think they have a "web version" ...

0
Nov 27 '08 at 8:41
source share

I just started developing a smart client application. These are the two options that I am considering.

Use the Microsoft System.AddIn namespace. It looks very promising, but it can be a little complicated for our final solution.

Or Smart Client - Microsoft UI Component Block

Recently, I have addressed the issue of how the Composite UI Application Block components and the System.AddIn namespace will create my own. Since the source code is available for CAB, it is easy to extend. I think our final solution will be a lightweight version of CAB, specifically using the Unity Application Block

0
Nov 27 '08 at 8:43
source share

The plugin architecture is becoming very popular due to its extensibility and, therefore, flexibility.

For C ++, the Apache httpd server is actually plugin based, but instead uses the concept of a module. Most apache functions are implemented as modules, such as cache, rewriting, load balancing, and even a streaming model. This is a very modular software that I have ever seen.

And for java, Eclipse is definitely plugin based. The core of Eclipse is the OSGI module system, which manages packages, another concept for the plugin. Bundle can provide extension points where we can create modules with less effort. The most difficult thing about OSGI is its dynamic characterization, which means that packages can be installed or removed at run time. There is no stop-peace syndrome!

0
May 14 '09 at 4:21
source share

If you work with .Net, our research has given two approaches: scenario and composition.

Scenarios

You extend the functionality of what your classes can do by organizing them with scripts. This means exposing what is compiled in your favorite .Net language into a dynamic language.

Some of the parameters that we found are worth exploring:

Structure

If you are starting a project with .Net 4 or higher, you should take a good look at the Managed Extensibility Framework (MEF). This allows you to extend the functionality of your applications with a plugin.

Managed Extensibility (MEF) is a compositing layer for .NET that enhances the flexibility, maintainability, and testability of large applications. MEF can be used for third-party plug-in extensibility, or it can benefit the loosely coupled plug-in architecture for regular applications.

The managed structure of the add-in is also well read.

0
Feb 26 '13 at 13:11
source share

Since I do not have enough comments to leave a comment, I am posting this as an answer. SharpDevelop is a development environment for developing applications in C # / VB.NET / Boo. It has a rather impressive architecture that allows you to expand it in several ways - from new menu items to development support for all new languages.

It uses a bit of XML configuration to act as a glue layer between the core of the IDE and the implementation of the plugin. It handles the placement, loading and version control of plugins out of the box. Deploying new plugins is a matter of simply copying into the new xml configuration file and the necessary assemblies (DLLs) and restarting the application. You can read more about this in the book โ€œDispersing the csharp Applicationโ€ by the original author (s) - Christian Holm, Mike Krueger, Bernhard Spide from the application. The book does not seem to be available on this site, but I found a copy that may still be here

A related question is also found here.

0
Jun 15 '16 at 23:41
source share

Instead of reinventing the wheel, use frames in your hand. Eclipse and Netbeans support plug-in extensions. You have to work in Java though.

-7
Nov 27 '08 at 8:38
source share



All Articles