Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plugin API vs Class Library API

Tags:

plugins

api

There is a lot of stuff here on what an API is, but I can't find what I need on the distinction between plugin APIs and class library APIs. I don't get it anyway.

In the book, Documenting APIs, I read: The key difference between a plugin API and a class library API lies in the which party supplies the implementation for the exposed API.

Plugin API: The publisher creates an application and exposes a plugin API; the 3rd > party developer implements the API. The 3rd party developer plugin extends the functionality of the publisher's application.

Class library API: The publisher creates the API and implements it. The end-user uses the class library via its API to write an application. With a class library, the publisher implements a library of functionality that exposes an API.

I think I understand the plugin. I'm not clear on the class library API. Is it like a printer manufacturer creating a driver based on an O/S class library so that their printer works with that O/S?

If so, could you explain more about the differences in the APIs themselves? Are they both still a set of exposed methods? And how does the publisher implement its own API?

References

Documenting APIs: http://www.amazon.com/documenting-APIs-writing-developer-documentation/dp/0963002104

What is the difference between a Java API and a library?

Difference between framework vs Library vs IDE vs API vs SDK vs Toolkits?

API vs Toolkit vs Framework vs Library

like image 352
genghis Avatar asked Oct 08 '22 17:10

genghis


1 Answers

They are both software interfaces. This means that they both look similar, typically a Java archive (JAR) containing a package (or multiple packages) with interfaces, classes, exceptions, etc.

I can understand why you found the explanation from the book confusing. As far as the API itself is concerned, the Java implementation is provided in both cases.

The major difference is in how this Java code is used. In the case of Plugin API (I like to call it Service Provider Interface, or SPI) you are primarily expected to add your own functionality by implementing the provided Java interfaces and/or extending the provided classes. On the other hand, you are only expected to call a Library API (I like to call it simply API), you are rarely expected to implement interfaces or extend classes.

Because of how they are used, there are many subtle differences between how you design an SPI and how you design an API. While I don't have a post dedicated to comparing SPI and API, when I discuss the various aspects of API design, I usually point out these differences:

http://theamiableapi.com/

like image 182
Ferenc Mihaly Avatar answered Oct 13 '22 10:10

Ferenc Mihaly