Re: Pagination (ISSUE-42)

Dear all,

> It seems, there's quite some pushback to separate paginated collections into collections and pages.

Though this summarizes the thread, it's actually not correct.
By definition, doing paging separates collections and pages.

As soon as we do paging, we have page resources.
So whether we name them as such or not, they exist.
It's therefore much better to be able to name them,
otherwise, we have no control over them whatsoever.

> My feeling is that even getting rid of the PagedCollection type seems to be the preferred approach at the moment.

That's totally fine; I don't see the explicit need for such a type.

> This would mean that there's always a sequence of collections but if there's just one, there's obviously no need to link to others.

That's less fine IMHO, because the sequence of collections _is_ the collection at the same time.

>  - remove the type PagedCollection
>  - rename itemsPerPage to numberItems
>  - drop the "Page" suffix from firstPage, nextPage, previousPage, lastPage

Fine with we, though not necessarily needed; but numberItems sounds vague.

> With this new design, a paginated collection would look like this:
> 
>  {
>    "@id": "http://api.example.com/an-issue/comments?whatever=3",
>    "@type": "Collection",
>    "first": "/an-issue/comments",
>    "previous": "/an-issue/comments?whatever=2",
>    "next": "/an-issue/comments?whatever=4",
>    "last": "/an-issue/comments?whatever=498",
>    "member": [ ...]
>  }

Where do we attach page numbers and total items then?
This modeling doesn't allow to do that correctly
(and this is simply because the model doesn't reflect reality).

> What we lose by this is the ability to distinguish whether a single "page" or the complete collection was referenced. It would always be the complete collection.

And that complete collection has then as many different URLs as there are pages?
That doesn't sound good.

> Ruben, I would be especially interested in hearing your opinion since you created ISSUE-42 [1] and mentioned that by implementing the LDF server it occurred to you that the current design is confusing. Do you see any practical issues with such a design?

The model doesn't reflect reality, so will lead to extensibility issues in the future.
No matter how we model things, pages will always exist.

Practical issues:
a) each URL of a page identifies the collection (only for Hydra, not for the real world nor other uses)
b) because of a), <comments?whatever=3> owl:sameAs <comments?whatever=2>, <comments?whatever=4>,
    and hence,  <comments?whatever=3> :next  <comments?whatever=3> and  <comments?whatever=3> :previous  <comments?whatever=3>,
    which is utterly meaningless and incorrect.
c) totalItems and numberItems cannot be meaningfully used

tl;dr: Let's model things like reality: pages exist, so we must be able to use them.

Best,

Ruben

Received on Friday, 13 February 2015 09:19:20 UTC