- 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
f,i,r,s,t
Admin
Yes...always normalize your data frist.
Admin
So april's fool is
Right?Admin
CSV is a nice format for data export/import because it's dead simple and can be modified very easily.
But he's using CSV as a data structure without ever writing it to disk!
Of course, TRWTF is that he replaced it with XML, of all things.. What's wrong with arrays?
Admin
Please tell me that someone typed this up rather than copy-pasting, and this bug wasn't in the original code.
Admin
Wow, I knew they butchered stories, but this is ridiculous. Submittter hear, and let me tell you- this isn't what happened at all. We were using CSV as the message body for SOAP packages across the network between the mainframe and the RDBMS through WebMQ. They somehow saw a pile of PERL code and decided it must be PHP, and invented this completely made-up story.
Captcha: illum Glad I could illum the facts for you.
Admin
Like Typical 'desi' typists at my firm ...
they will not do what we ask them to do, but will want to modify code which has worked for ages to make it go a few milliseconds faster ...
Tye does not approve ...
Admin
Now this is how you do a 1st April joke :)
Admin
Why would you convert your data to "anything" if you're generating the HTML server-side? You could even generate the HTML directly from the DB result set (ugh!)
Admin
Yours doesn't have anything in common except the CSV part. In the story there's nothing about SOAP, PHP or mainframes. Also, I'm not sure if any sane Perl developer would use Visual Studio.
Admin
That's a lovely combination of PHP and VBScript!
Also, it doesn't seem to really be CSV, just a list of IDs separated by commas. CSV implies you have tabular-ish data, with structure (a fixed number of fields) and possibly a variable number of records. Neither is the case here.
Admin
Admin
Yeah, APerlo doesn't know what the hell he's talking about. I submitted this code, and I found it at site I was contracting for. Of course, the entire system was in Classic ASP, so I don't know why they mutated some of the code into PHP.
Oddly, they did use WebMQ at that company. I wonder if APerlo was at the same place?
Admin
Now it's more Enterprisey
Admin
Is that supposed to be the April Fool's joke, that the code's this odd mishmash of PHP and VB?
Admin
Submitter here. editors anonymized. actually should be that we used JSON. hope that clears up.
Admin
"...you'd only be able to pry CSV from PHP's cold, dead heart."
FTFY
Admin
Of course! XML to the rescue. I guess it was tab-separated XML containing base 64 encoded JSON, right?
The only sensible thing to do.
Admin
I'm the submitter and the President's sick daughter!
Admin
OP here...There's a typo in the code...to wit:
sb:
Boundary length overflow created the "Extra Option" WTF and made me facepalm. Twice.
Admin
I'm the submitter.
Actually, the real code pushed the values out to a mobile app (heck yeah, everyone knows mobile is the future!) running on a retina iPad sitting on a wooden table, which then took a photograph of itself using a carefully placed mirror...
Captcha: ABBAs. They were the SQL queens, young and sweet coding PHP...
Admin
Stuck. In. Head. Thanks for the psi-rickroll, jerk. =(
Admin
By carefully placed, you mean a circular mirror tied in the center to a string tied to the ceiling.
Why people have to carefully place level down-facing mirrors is beyond me.
Next thing you know, someone's going to reinvent the plumb
Admin
It was in FORTRAN running on a custom-modified BBC-B and it used semicolons to separate the fields and saved the data on a cassette tape recorder plugged into the audio-out socket.
Admin
Admin
Submitter here. The code was actually in VB.Net, which is why I used the Visual Studios plugin.
Captcha: tranjlate: a mistranslated version of translate.
Admin
I am Spartacus.
Admin
Seriously, you have a way of starting stories by difficult-to-read, puzzling language, that makes me tired quickly cause I have to read whole sentences multiple times, even parts of some. Maybe it's just me. Sometimes it's fun. I'm giving up on this one today.
Admin
To be fair, I also continue the story with difficult-to-read, puzzling language, that makes you tired quickly-- and I end the story with difficult-to-read, puzzling language, that makes you tired quickly.
So maybe the problem is that you aren't getting enough birch sap in your diet.
Admin
sub. here. I submitted so Remy would do this story and I'd get to see unicorns. =(
(Why won't the forum let me post with my own name? Some AC stole my name.)
Admin
Is it just me, or do many (most?) WTFs derive from SQL or some derivative of it, then REALLY become a WTF when someone attempts to deal with the results of SQL.
Sure, there are WTFs from other languages Perl, PHP, Python, etc. but when you count them against those that have SQL, things just get passed by.
Than again, I fully recognize there are "FILE_NOT_FOUND" and Paula Bean problems, those don't crop up too often by comparison.
Ah, common sense, that which is in short supply (SIGH).
Admin
"Reynard thought about educating the lead programmer on normalized data."
I used to think there were two categories: normalized data, and not.
But I'd guess this falls in a whole other category: Abnormalized data.
Admin
It's a WTF any time someone uses CSV. Despite the name, CSV is not a standard. Not nowhere, not nohow.
Here's a good article on why: www.fourthworld.com/embassy/articles/csv-must-die.html
Admin
Submitter here: My boss recognized the code. I'm getting written up for "publishing company secrets".
Admin
Actually: for (int i = curItemArr.length; i >= 0; i++) in C++ finishes as soon as there is overflow, but unfortunatelly does not visit any valid index.
On the other hand this pattern: for (unsigned int i = $curItemArr.length; i-- <= curItemArr.length;) even though looks strange, is quite correct for unsigned integers when you want to iterate backwards.
Maybe someone mixed them together.
The interesting idea is to use O(n*m) algorithm, in the effort to not have SQL Injection, hidden assumptions about equality relation, and comparability and existence of perfect hash function. Actually I would do the same.
Admin
If you ever parse CSV, please do something more than split(","...). Some people use , in values, keys, some even use them inside numbers. Think about quotes then, too. And then, do not forget about slashes. Also, anyone knows why google docs, when importing CSV does not default to using Comma as separator?
Admin
The real WTF there is all that extra vertical space being wasted with extra newlines and curly braces on a line by themselves...
Admin
Not a WTF, a stylistic choice. Every shop I've worked at that uses C# has stuck to that convention for some reason.
Sure, one could probably save a byte or two with the /r/n removed...but in the end, who cares? It's not the biggest WTF in those snippets.
Admin
No, I'm pretty sure I was the one who submitted that code. It was originally written in INTERCAL, though, so I'm not surprised that there were some mistakes in the translation.
Admin
I am the submitter and I know something you don't know. I am not left-handed
Admin
Yeah, that was a problem back when we used hard copy terminals like the TTY-43. However, not really a problem these days is it?
Admin
Admin
Bee?
Admin
While I agree tabs or vertical separators make better delimiters, there's nothing wrong with collapsing thousands of values into a single field for storage in a session variable. Most of the supposed CSV strings are actually space delimited in this code. If there's a delimiter dumber that a comma, it's a space.
Delimited format is more efficient than XML and JSON encoding in terms of storage and is a better choice for non-heirarchical data for caching/storage purposes. For SQL storage, where indexing is important, field length can mean the difference between indexing in memory vs heavy disk I/O.
The thousand lookups into the session array are eliminated, replaced with a single encode/join/implode or decode/split/explode. Collapsing variable data like this allows it to be read atomically from a user key rather than building it from thousands of records. That improves overall index performance if the field in question doesn't need to be indexed.
I'd be more worried about the unnecessary double passes thru the database. The CSV string built for the SQL query drops the number of queries from thousands to one, but the ID should be stored in the session with the value. The point of the session being to eliminate the db access wherever possible.
And all that wasted vertical space is a by-product of Microsoft syntax-controlling editors.
Admin
Jeez, it's values and it's got commas stuck in between. I don't see the problem.
Admin
Actually, what you observed are two separate facts: Most programmers are idiots. Programmers often use a database.
Combine these two and you end up with a lot of WTFs revolving around database (mis)use.
Admin
The story is obviously extraordinary interesting, judging by the measly number of comments it attracted by this hour. So, maybe you're not getting enough.
Admin
Admin
Admin
I'm the original submitter. I submitted Remy to the universe, therefore by regression I submitted everything here. QED