Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "Opinionated API" mean?

Tags:

python-3.x

api

I came across the term "Opinionated API" when reading about the ssl.create_default_context() function introduced by Python 3.4, what does it mean? What's the style of such API? Why do we call it an "opinionated one"?

Thanks a lot.

like image 464
clasnake Avatar asked Feb 16 '15 06:02

clasnake


1 Answers

It means that the creator of the API makes some choices for you that are in her opinion the best.

For example, a web application framework could choose to work best with (or even bundle or work exclusively with) a selection of lower-level libraries (for stuff like logging, database access, session management) instead of letting you choose (and then have to configure) your own.

In the case of ssl.create_default_context some security experts have thought about reasonably secure defaults to configure SSL connections. In particular, it limits the available algorithms to those that are still considered secure, at the expense of complete compatibility with legacy systems, a trade-off that is beneficial in their (and my) opinion.

Essentially they are saying "we have a lot of experience in this domain, and we really think you should do things in the following way".

I suppose this is a response to "enterprise" API that claim to work with every implementation of as many standard interfaces as possible (at the expense of complexity in configuration and combination, requiring costly consultants to set up everything).

Or a natural extension of "Convention over Configuration".

Things should work very well out-of-the-box, so that you only have to twiddle around with expert settings in special cases (and by then you should know what you are doing), as opposed to even a beginner having to make informed decisions about every aspect of the application (which can end in disaster).

like image 148
Thilo Avatar answered Nov 15 '22 20:11

Thilo