Skip to content

Mutable vs Immutable Transition #8

@smizell

Description

@smizell

I wanted to discuss a couple of things in Z's MSON doc. IMO, I think it's getting really close! I wanted to discuss something specifically from my other issue #7. First, here's the document.

MSON Document

Hypermedia Resource

  • attributes (Collection: Attribute)
  • transitions (Collection: Transition)
  • meta (Meta)
  • resources (Collection: Embedded Hypermedia Resource)

Attribute

  • name
  • value

Transition

  • relation_type
  • uri
  • attributes (Collection: Input)
  • parameters (Collection: Input)
  • meta (Meta)

Input

  • name
  • default_value
  • value

Meta

  • attributes (Collection: Attribute)
  • links (Collection: Transition)

Embedded Hypermedia Resource

  • relation_type
  • Include Hypermedia Resource

Collection: T

Generic collection, possibly with language specific implementation, array, linked list, hash etc.

Thoughts

Right now, we have the idea of a Transition and an Embedded Hypermedia Resource. I'm curious if it would be better to instead make a distinction between Mutable Transitions and Immutable Transitions instead. In the MSON above, all transitions have attributes that are inputs. In reality though, any embedded attributes on a GET request MUST be considered immutable. My thought is, not all transitions should have attributes that are considered an Input.

Additionally, (this is a personal opinion at this point) I believe that an embedded resource is a sub category of an Immutable Transition, along with the idea of a link and a query. If you look at the MSON above, you can see the similarities in the Transition and Embedded Hypermedia Resource.

If you look at my code, there is really no difference between a link and an embedded resource. A query has additional parameters, and an action has mutable attributes. I think it's important to consider all of these to be transitions, while also recognizing these different categories of transitions. This would be:

Safe, Immutable Transitions

  • Links (safe method, no query params, immutable attributes)
  • Queries (safe method, with query params, immutable attributes)
  • Embedded Resource (safe method, no query params, immutable attributes)

Unsafe, Mutable Transitions

  • Actions (unsafe methods, mutable attributes)

There would be other categories to add as well, such as templated links and templated actions. I'll leave this for discussing later.

I think these distinctions will also be important as we start building adapters. For instance, HAL only supports links and embedded resources from the listed above.

Hope this helps!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions