Matt Kruse wrote on 01 feb 2010 in comp.lang.javascript:
Bad implementations are not uncommon on the web, Matt,
so commonness does not imply solution quality or logic.
In webappps, for example, long results tables can be very handy to
sort, filter, and manipulate on the client-side. It is much faster
than going back to the server each time, and can be done off-line.
Getting a "dump" of data into a static html document to be handled
later is handy.
Long tables are also good for scanning and getting a feel for how the
results relate to each other. For example, if the rows are colored by
some scheme or if there is a horizontal bar chart in each row, then
scrolling up and down on the table can give the user a quick visual
idea of how the data relates and where logical chunks or groupings of
data exist.
What can be inefficient or optimized about solutions
that "perform just as well"?
There are cases, even without long tables, where the efficiency of a
sort algorithm matter. For example, try creating a more complex table
with multiple tbody tags, a tfoot, colspans and rowspans, more than 25
columns containing complex markup, etc. An inefficient solution may
become unusable with only a couple hundred rows.
During my testing and optimizing of my table sort code, I found that
optimizing for IE6 makes a big difference. Even on shorter tables, you
can cut a second or more off the user's sort time. That is huge in
terms of the user's perception of how quickly the application is
responding.
Short, easily readable and easily debuggable code
is the only efficiency gain to be won when the performance is just as well.
Don't forget flexibility. Your shorter code works in the most
simplistic of cases, but if a developer is faced with a situation
where it breaks, they may not know how to fix it. There are pros and
cons to each way of doing it. Which is why "simplest and best" in the
subject is asking for too much!
Simple, Efficient, Robust. Pick two!
Matt Kruse