...

/

Defining Minimum Viable API

Defining Minimum Viable API

Learn to build a minimum viable API by using the smallest set of macros possible.

Designing the API

Now that we know the kind of DSL we would like to build, we need to decide how to design our API. The HTML spec includes some 117 valid tags, but we need a smaller surface area to begin our DSL. At this point, we might be tempted to fire up our editor and start defining all 117 tags as individual macros. There’s a better way. Since we define a mini-language with macros when creating DSLs, the best way to begin is to define the smallest set of macros possible to serve as a basis for the broader macro DSL.

Instead of immediately planning to support the entire HTML spec as macros, let’s start with a refined set of macros that can still speak the HTML language.

The smallest API of our HTML library would contain a tag macro for tag construction, a text macro for injecting plain text, and a markup macro to wrap the entire generation block. These three macros will serve as a small, focused base of our implementation. They’ll let us quickly get together a ...

Access this course and 1400+ top-rated courses and projects.