Sent from my iPhone
On 26 Oct 2012, at 05:51, Jørn Wildt <j...@fjeldgruppen.dk> wrote:
> I have been thinking a bit about this issue and come to the conclusion that the HAL approach where rels are indexed in a dictionary has some problems. Let me try to explain:This isn't a big deal. You should obviously avoid churn by getting the plurality right first time (usually obvious). In cases where you don't, then just treat it like you would any other breaking change - by introducing an additional rel. i.e. either pluralize the rel or if you dont like plural rels change it some other way and keep it singular.
> To lookup a rel-value, say "printable", a client programmer would do like this, since HAL is optimized for the simple/most-used use case:
> var url = data._links["printable"].href;
> But what happens if the server decides to throw in multiple links for the same rel-value, for instance both PDF and Word representations of the printable stuff? Well, the above code breaks since data._links["printable"] would become an array instead of a single value.
> Now a robust client has to write code like this:
> var url = null;
> Unfortunately the dictionary approach encourages programmers to write the simple client code, assuming there will only be one link for each rel-value. This means encouraging programmers to write code that will break when the server decides to throw in multiple links for each rel-value.
> A robust client would always have to write code that somehow respects that it may have to traverse an array to find the link it is looking for. So why not always use an array like this:
> _links : [
> In that way we encourage (force) client programmers to write code that always iterates through the link array - instead of encouraging them to write brittle code that will break later on?
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.