• Anonymous (unregistered)

    f,i,r,s,t

  • RFoxmich (unregistered)

    Yes...always normalize your data frist.

  • Rnd( (unregistered)

    So april's fool is

    Reynard thought about educating the lead programmer on normalized data. He was able to replace all the CSV with a bit of XML, and all was right in the world.
    Right?
  • imgx64 (unregistered)

    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?

  • (cs)
    for ($i = $curItemArr.length; $i >= 0; $i++) 

    Please tell me that someone typed this up rather than copy-pasting, and this bug wasn't in the original code.

  • APerlo (unregistered)

    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.

  • typicalDesi (unregistered)

    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 ...

  • (cs)
    He was able to replace all the CSV with a bit of XML, and all was right in the world.

    Now this is how you do a 1st April joke :)

  • (cs)
    He was able to replace all the CSV with a bit of XML

    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!)

  • (cs) in reply to APerlo
    APerlo:
    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.

    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.

  • Daniel (unregistered)

    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.

  • Daniel (unregistered) in reply to pjt33
    pjt33:
    for ($i = $curItemArr.length; $i >= 0; $i++) 

    Please tell me that someone typed this up rather than copy-pasting, and this bug wasn't in the original code.

    I'm guessing this was originally VBScript, hastily anonymized into PHP, probably by someone that doesn't have much experience in this language. There are lots of inconsistencies here, like occasional variables without sigils, string concatenation with "+", method invocation with ".", and ASP-like API (I guess; it's been 10+ years since I last saw this), despite the PHP-ish $_SESSION and other features. So don't read too much into these errors, just appreciate the general idea.

  • Gary Kurtz (unregistered) in reply to ubersoldat

    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?

  • cybaz7 (unregistered) in reply to ubersoldat

    Now it's more Enterprisey

  • (cs)

    Is that supposed to be the April Fool's joke, that the code's this odd mishmash of PHP and VB?

  • Reynard (unregistered)

    Submitter here. editors anonymized. actually should be that we used JSON. hope that clears up.

  • (cs)

    "...you'd only be able to pry CSV from PHP's cold, dead heart."

    FTFY

  • _darkstar_ (unregistered)
    Reynard thought about educating the lead programmer on normalized data. He was able to replace all the CSV with a bit of XML, and all was right in the world.

    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.

  • Anonymous Paranoiac (unregistered)

    I'm the submitter and the President's sick daughter!

  • Laundry Day (unregistered)

    OP here...There's a typo in the code...to wit:

    $i = $curItemArr.length; $i >= 0; $i++

    sb:

    $i == $curItemArr.length + 1; $i >= 0; $i++

    Boundary length overflow created the "Extra Option" WTF and made me facepalm. Twice.

  • Foo Bar (unregistered)

    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...

  • (cs) in reply to Foo Bar
    Foo Bar:
    Captcha: ABBAs. They were the SQL queens, young and sweet coding PHP...

    Stuck. In. Head. Thanks for the psi-rickroll, jerk. =(

  • Valued Service (unregistered) in reply to Foo Bar
    Foo Bar:
    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...

    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

  • (cs) in reply to Foo Bar
    Foo Bar:
    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...

    No, I submitted this code, and so did my wife!

    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.

  • (cs) in reply to ubersoldat
    ubersoldat:
    I'm not sure if any sane Perl developer would use Visual Studio.
    Perl and sane? I'm guessing that VS use must in that case be common among Perl users.
  • Laundry Day (unregistered)

    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.

  • Spartacus (unregistered)

    I am Spartacus.

  • abico (unregistered)

    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.

  • (cs) in reply to abico
    abico:
    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.

    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.

  • Half-Reflected Almond (unregistered)

    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.)

  • (cs)

    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).

  • (cs)

    "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.

  • El Ka-Ben (unregistered)

    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

  • Reynard (unregistered)

    Submitter here: My boss recognized the code. I'm getting written up for "publishing company secrets".

  • qbolec (unregistered)

    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.

  • qbolec (unregistered)

    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?

  • BillR (unregistered)

    The real WTF there is all that extra vertical space being wasted with extra newlines and curly braces on a line by themselves...

  • Xarthaneon the Unclear (unregistered) in reply to BillR
    BillR:
    The real WTF there is all that extra vertical space being wasted with extra newlines and curly braces on a line by themselves...

    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.

  • neminem (unregistered)

    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.

  • Inigo Montoya (unregistered)

    I am the submitter and I know something you don't know. I am not left-handed

  • Steve Holdoway (unregistered) in reply to BillR
    BillR:
    The real WTF there is all that extra vertical space being wasted with extra newlines and curly braces on a line by themselves...

    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?

  • Pock Suppet (unregistered) in reply to El Ka-Ben
    El Ka-Ben:
    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

    Eh?
  • (cs) in reply to Pock Suppet
    Pock Suppet:
    El Ka-Ben:
    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

    Eh?

    Bee?

  • AC (unregistered) in reply to Pock Suppet

    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.

  • Tractor (unregistered) in reply to Daniel
    Daniel:
    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.

    Jeez, it's values and it's got commas stuck in between. I don't see the problem.

  • Tractor (unregistered) in reply to herby
    herby:
    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).

    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.

  • augue (unregistered) in reply to Lorne Kates
    Lorne Kates:
    abico:
    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.

    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.

    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.

  • (cs) in reply to Coyne
    Coyne:
    "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.

    Have you heard the Boyce of Codd?

  • JJ (unregistered) in reply to Matt Westwood
    Matt Westwood:
    No, *I* submitted this code, and so did my wife!
    Welease Westwood!!
    TFA:
    // Comma seperated list
    Fer chrissake, learn how to spell "separated"!
  • God (unregistered) in reply to JJ

    I'm the original submitter. I submitted Remy to the universe, therefore by regression I submitted everything here. QED

Leave a comment on “Tough to Separate”

Log In or post as a guest

Replying to comment #:

« Return to Article