Composable by design, sensible by default

Plug: I help develop million: <1kb virtual DOM – it’s fast!

Introduction

Lately, there’s been a paradigm shift in API design in the JavaScript Framework ecosystem. For instance, Vue 3 has released the new Composition API alongside the …


This content originally appeared on DEV Community and was authored by Aiden Bai

Plug: I help develop million: <1kb virtual DOM - it's fast!

Introduction

Lately, there's been a paradigm shift in API design in the JavaScript Framework ecosystem. For instance, Vue 3 has released the new Composition API alongside the existing Options API, allowing for creation of significantly more reusable code and greater customization by the developer.

This is in contrast to the previous API in Vue 2. Although it provided functionality to a degree, it is fundamentally a black box and when greater complexities arise, plugins or escape hatches must be utilized to solve these issues. This can result in subpar code quality, performance, and maintainability.

Composability by design

Composability is awesome, but what exactly is composability?

Instead of a boring definition, let's illustrate with a graphic:


Lego pyramid made of Lego blocks

We can imagine Legos as components of our API -- we can use those legos to build complex logic. If we want to change the color or length of the pyramid, we can swap out legos for legos of our desired attributes. When applied to APIs, we can use components to compose more complex logic, and we can swap out components to change the logic.

For example, with Million, logic is composed with drivers, which are functions that enable nested composition. This is especially useful for libraries that are made to create other libraries, as it allows for greater extensibility and complex functionality.

Sensible by default

While having a super composable API is great, it can be too much effort just to get some simple functionality working. That's why we need to offer a sensible API by default. A sensible API is one which covers the general case and uses best practices, and is dead simple to use.


This content originally appeared on DEV Community and was authored by Aiden Bai


Print Share Comment Cite Upload Translate Updates
APA

Aiden Bai | Sciencx (2021-11-03T05:58:35+00:00) Composable by design, sensible by default. Retrieved from https://www.scien.cx/2021/11/03/composable-by-design-sensible-by-default/

MLA
" » Composable by design, sensible by default." Aiden Bai | Sciencx - Wednesday November 3, 2021, https://www.scien.cx/2021/11/03/composable-by-design-sensible-by-default/
HARVARD
Aiden Bai | Sciencx Wednesday November 3, 2021 » Composable by design, sensible by default., viewed ,<https://www.scien.cx/2021/11/03/composable-by-design-sensible-by-default/>
VANCOUVER
Aiden Bai | Sciencx - » Composable by design, sensible by default. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/11/03/composable-by-design-sensible-by-default/
CHICAGO
" » Composable by design, sensible by default." Aiden Bai | Sciencx - Accessed . https://www.scien.cx/2021/11/03/composable-by-design-sensible-by-default/
IEEE
" » Composable by design, sensible by default." Aiden Bai | Sciencx [Online]. Available: https://www.scien.cx/2021/11/03/composable-by-design-sensible-by-default/. [Accessed: ]
rf:citation
» Composable by design, sensible by default | Aiden Bai | Sciencx | https://www.scien.cx/2021/11/03/composable-by-design-sensible-by-default/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.