Archive for the ‘page’ Category

Pagination

Friday, September 1st, 2006

Kevin Clark’s Things You Shouldn’t Be Doing In Rails article is causing some consternation in the Railsosphere. Particulary the pagination comment:

I haven’t used pagination in my last 15 projects. The pagination code is ugly. Ugly ugly.

There are two parts to his comment. The first is that the implementation of pagination that everyone first gets with Rails is poorly done. It is not scalable and is inflexible.

“So what do we use instead?” is being asked by many and there has been no real answer beyond the obvious answer; write your own pagination code that fits your application.

The second part of the pagination comment though is more interesting. Brian Hogan comments:

Pagination of “next / previous” is pretty useless on large data sets anyway. Alphabet bars or searches are much better approaches for filtering data in my opinion and they’re easy to implement.

That is very interesting. Yes, there will be times that pagination is the only logical way of cutting datasets up but they are rare, very rare.

But everyone uses pagination! Google does!

That is because it is easy. Maybe not easy to implement but easy to conceptualise. It is dead easy to say “List the data in chronological order in pages of 20 records.”

Instead you should be thinking hard about the data you are presenting. If your data is timely then page by logical date ranges (hour, day, month, range etc.) and not just chronological + page sets.

If your slicing results in too long a list to display on one page then you need to slice it better, not just stick in page numbers.

Google is a good example. When I search and don’t find the result I want on the first page I don’t go to page 2. I research. I refine my search.