- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
"Paging algorithm" didn't mean what you think it does, back in the days of the dinosaur. It meant ways to decide which page goes in the pagefile. In fact, this concept is probably almost old enough to qualify for having been designed by trilobites.
Admin
Back in those days "next page" and "previous page" were always implemented by turning over a piece of paper. This wtf isn't as prehistoric as advertised; these dinosaurs are too modern.
Admin
That's not a 'curious perversion', that's just plain wrong.
Admin
Still makes you wonder why the user got 75 records when from the look of it this code should only give the first 30.
Admin
I like that the offset variable is called "limit".
Admin
What.
Admin
50+25 = 75
Admin
This was a lovely story about dinosaurs... why'd you have to ruin it with algorithms, eh?
Admin
Arrgh. Unicorns! (haven't seen them for a while)
Admin
75 records should be more than enough for anyone!
Admin
Yeh... I read this and expected to see something about demand paging in virtual memory systems and was looking forward to seeing some subtle race condition or low bandwidth covert channel attack sigh
Should have known better... just one of those frist page second pages thrid page things.
Admin
There can ONLY be THREE!
Admin
Who's going to need more than three pages of data, anyway?
Admin
Admin
Admin
Clearly some hotshot developer figured he could get a buck or two adding a few pages to the system every now and then, not expecting someone to come along and need a ton at once.
Admin
The code is a bit shortsighted, but in all fairness if the users are paging through more than three pages records they should probably refine their search terms.
Admin
s/paging/pagination/g;
Admin
Rats. And I thought my frist comment saying just "fr" was quite relevant and witty. Shame all frist comments are now automatically purged.
Never mind, back to reading the remaining boring humourless diatribes.
Admin
Turn on javascript you freeloading schmuck
Admin
Admin
Then there is something very wrong with you.
Admin
TRWTF is that they didn't use a switch statement, amirite?
$page = (int)$_GET['page']; switch($page){ case 1:{$limit = 0;$this_page = 1;$prev = 1;$next = 2;}break; case 2:{$limit = 25;$this_page = 2;$prev = 1;$next = 3;}break; case 3:{$limit = 50;$this_page = 3;$prev = 2;$next = 3;}break; default:{$limit = 0;$this_page = 1;$prev = 1;$next = 2;}break; }
There you go, much better!
Admin
THERE ARE FOUR PAGES!
Admin
That he ever said "640K is Enough For Anyone" was debunked so many times already...
Admin
Of course, we only have your word for it that he ever said that.
Admin
In times of PRISM and TEMPORA, it is very wise to limit the amount of accessible data. So the developer just added his variant of a data protection layer. Why can't you see that???? This was written by a true hero, fighting for your freedom!!!
Admin
More to the point, even if we were to take your word for it that he ever said that, we then have to take his word for it that he never said that.
Admin
He purged the interwebs before he left Microsoft. That NSA stuff that we're hearing about now? His top engineers wrote that initially as a universal search and replace, and tested it by replacing that quote with Ballmer's "developers" rant. Bill had a bit too much Aqua vitae and was feeling frisky when he first turned it on.
Admin
This is no bug: The users just need to shell out for the Enterprise Edition.
Admin
More like: 640K is as much as anyone can afford right now.
You paid $100-$200 for each row of DRAM you installed. I read the computer lab copy of "Creative Computing" every month. The system prices, at a grand or so -- even for the homebrew/hobbyist systems, were a world away for someone who didn't even get an allowance. The business systems, with a VDT and a hard drive or two, were in the next galaxy at 10+ grand.
Admin
TRWTF is DRY.
There, FTFY.Admin
Love the TNG "Chain of Command" reference. Picard FTW!
Admin
Admin
Where's the WTF?
Bug closed. WORKS PER DESIGN
Admin
Right or wrong, this is what he always said back in the days!
Admin
That's a MySQLism. Selection with a "LIMIT x, y" clause has "x" being the offset and "y" being the number of records to return.
http://php.about.com/od/mysqlcommands/g/Limit_sql.htm http://dev.mysql.com/doc/refman/5.0/en/select.html
...it's perhaps the least illogical thing about this code, despite its general obtuseness.
Admin
No. It should be, "Right or wrong, this is what they always quoted him saying, back in the day!"
Right or wrong precedes something that actually was done. Not something provably never done. Specifically something that has been debated before.
Right or wrong, people believe in God. Whether she is right or wrong, this is my country.
Not
Right or wrong, God exists. Right or wrong, my country invaded mars.
Admin
Right or wrong, that is what Hannes posted back a few hours ago.
Admin
The best algorithm is a hard-coded algorithm. No need to worry about what happens when the inputs get too large. Nope, this algorithm is guaranteed to never ever cause the application to crash and burn. Kudos to the developer who wrought this work of art!
Admin
Actually, that last one does work -- you just have to interpret "right or wrong" as being a statement of moral ambiguity, not factual accuracy.
Admin
If you think about how short T-rex arms are, and then look at the keypad on the right side of the keyboard, it's obvious that they couldn't reach the third row. Easy to explain.
Admin
Right or wrong, this is simply how paging was handled back in those days.
Captcha 'ratis' - I don't give a ratis ass how many records you have, I'm only giving you three pages of data.
Admin
It's robustuse!
Admin
Please be considerate I had a brother that was largely unscathed in a dramatic paging accident.
The paper cut took hours to heal! HOURS!
Admin
And I'm guessing the QA person (there was a QA person, right???) looked at page 1 -- OK; page 2 -- OK; page 3 --OK; Probably works for all pages. Signoff, go on to next task.
Unfortunately, QA often has limited time, and can't test EVERY page. So this code passes; and no one knows until a customer tries page 4.
Admin
Maybe limit=0 is supposted to mean unlimited.
Admin
And that is the correct way to use it.
Admin
Admin
And how would you know it couldn't be more than 4 if your testing environment didn't have more than 75 records.
And how would QA know on a testing environment with more than 75 records, if QA didn't anticipate stupid and always put some amount of search criteria.
And how would QA know if they left off search criteria and the result reported no more than 75 entries, if QA wasn't tracking how many entries existed.
And how would QA know if there wasn't more than 65535 pages?
Me thinks it's time to add a go to last page feature.