Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Going Beyond JSON: Representers, ASTs, and Code

Avatar for Stephen Mizell Stephen Mizell
September 28, 2018
47

Going Beyond JSON: Representers, ASTs, and Code

This talk was given at REST Fest. It's a way to view JSON as a language rather than interact directly with the format. It also goes into the idea of the representer pattern.

Avatar for Stephen Mizell

Stephen Mizell

September 28, 2018
Tweet

Transcript

  1. Refract { "element": "object", "content": [ { "element": "member", "content":

    { "key": { "element": "string", "content": "name" }, "value": { "element": "string", "content": "John Doe" } } } ] }
  2. Abstract Source Tree A tree representa*on of the abstract syntac*c

    structure of source code wri5en in a programming language.
  3. Treat your formats—JSON and others—as languages. Treat them as DSLs.

    Parse them to canonical structures decoupled from the format itself.
  4. Coupling to HAL { "_links": { "item": { "href": "..."

    } } } // Get the item link doc._links.item.href
  5. Coupling to HAL { "_links": { "item": [ { "href":

    "..." }, { "href": "..." } ] } } // Broken! doc._links.item.href
  6. Your data model is not your object model is not

    your resource model is not your message model. — Mike Amundsen
  7. Takeaways • Define boundaries • We shouldn't have breaking changes—clients

    should just degrade • Consider inputs/outputs as languages • Think about canonical structures for crea?ng unity in a world of diversity