js-url-gen icon indicating copy to clipboard operation
js-url-gen copied to clipboard

Declarative API development

Open patrick-tolosa opened this issue 3 years ago • 0 comments

The case for Declerative APIs

The current API of the SDK is imperative. @yoadsn mentioned in #382 that some users would benefit from a declarative API as well.

Points of interest

  • The API should be consistent across methods (Meaning we can't pick and choose which APIs have a declarative counterpart)
  • The API should avoid using magical strings since we aim to provide the best dev experience even to people with weak IDEs.
  • We might relax the constraint above if we consider the declarative API for more advanced users, but this needs to be explored before deciding.

Trivial example

Imperative

new Image().resize(scale().width(100).height(100)) 

Declerative

new Image().resize(scale({
  width: 100,
  height: 100
}))

patrick-tolosa avatar May 27 '21 07:05 patrick-tolosa