User:Jacek Antonelli/Plugin System

My personal thoughts on the Plugin System. Use the talk page if you have comments about this.

Why APIs Should Be Abstracted
It's important that any API we design be highly abstracted. That is, the API should reflect the core concepts of the system, not any specific implementation. The reason for this are simple:


 * 1) Implementations change, but interfaces should not. If the interface is too closely tied to the implementation, than you can't (easily) change the one without changing the other.
 * 2) An API which is not tied to a specific implementation is a good candidate to become a standard across multiple implementations. That means that a plugin written for Imprudence could work on another viewer with a different implementation, as long as they both offer the same abstracted API.

Example: HTML
An example of this is HTML. The same web page can be viewed on many different browsers, even though their implementations may be radically different. The reason this is possible is that HTML provides an abstract language for expressing documents, which is abstracted from any specific implementation. A web browser could have a separate class for bold text as it does for regular text, or it may not, and it doesn't make a difference to the HTML. (Of course, some web browsers do not comply with the language standards, so they display some pages incorrectly, but this is the fault of the browser, not of HTML.)

Fundamental Properties vs Implementation Details
Applied to the plugin system API, it means that we have to ask, "What are the fundamental properties and actions of the thing this part of the API is describing?", not, "What variables and methods does this class have in the C++ code?".

For example, the UI widget for a menu fundamentally has a text label and a list of children. If you removed either of those things, it wouldn't be a menu. Also, like all UI widgets, it can be active or inactive, visible or invisible. These are common properties of all UI widgets, regardless of implementation details.

A plugin should be able to rely on every implementation supporting these fundamental properties. Therefore, every implementations should be required to provide them in order to be considered API-compliant.