Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does this API design pattern have a name?

Both jQuery and MathBox have query functions ($() and select()) which return objects with methods attached which act on all queried entities. E.g. $().addClass().

Does this pattern have a name?

like image 961
bgoosman Avatar asked Mar 21 '21 06:03

bgoosman


People also ask

What is API-first design?

The API-first design means that the software development team builds it ahead of the rest of an application. For example, the team designs API using GraphQL and Schema Definition Language (SDL). This definition becomes a single source of truth. Based on that, engineers generate fragments of application.

Why is API design important for fintech APIs?

They should be reliable, accessible, and usable by anyone, anytime. By starting with API design, you can make sure that everything looks and works as intended. It’s especially important for FinTech APIs, where the level of product complexity and third-party integration can be pretty high.

What is an application programming interface (API)?

Application programming interface delivers in spades. The APIs used in the API-first design, fall into three categories: The first kind is used for the purpose of simply building application. The second one is used for orchestration, composable APIs, and microservices.

What is the difference between adapter pattern and façade pattern?

Adapter pattern will have the same method name. X.DoSomething () will do different thing when it applies to different object. Façade pattern accesses different functions in separate different classes. Example of façade class should be when you want to create a validator class.


2 Answers

I've always heard jQuery API style being called "Fluent API", or as Wikipedia says: "Fluent Interface".

Check https://en.wikipedia.org/wiki/Fluent_interface#JavaScript

However, it's mainly about chaining methods, usually to build queries or transformation chains. What the methods do and how they act on the handled entities depends on the application domain.

For the case of jQuery, it's similar to a composite pattern: an action can be applied on a single entity or a collection of them transparently, using the same interface. The difference with the classic Composite design pattern is that we're not talking about pure OOP, but about something closer to functional programming where returned values always forward the API, though with a new state.

Check https://en.wikipedia.org/wiki/Composite_pattern

like image 196
Yannick Meine Avatar answered Oct 20 '22 17:10

Yannick Meine


It's called a Higher Order function.

A Higher Order Function is any function that returns a function when executed, takes a function as one or more of its arguments, or both. If you have used any of the Array methods like map or filter, or passed a callback function to jQuery’s $.get, you have already worked with Higher Order Functions.

ref

like image 35
Robert Harvey Avatar answered Oct 20 '22 17:10

Robert Harvey