• bob (unregistered) in reply to Ouch!

    excellent

  • causa (unregistered) in reply to RogerC
    RogerC:
    AdT:
    kastein:
    He had something against loop variable incrementing?

    It's overused anyway. ;)

    I used to write code like this:

    for (pInput = pInputBuffer, pOutput = pOutputBuffer, szRemainingBytes = szBytesToCopy;
         szRemainingBytes; *pOutput++ = *pInput++, --szRemainingBytes);

    until a University tutor pointed out that for loops were invented to make code more readable.

    Do you have something against memcpy?

    Don't know about him, but I sure do. It's notoriously unsafe and the culprit of many security holes in c/c++ software. Many big software houses that take security seriously either banned the use of it, or you need a very good reason to use it.

  • Jan (unregistered)

    I would really like to know what would happen if one of the "fixed lenght" fields were to contain, say, a lesser-than sign.

    If the producer is as badly written as this consumer it would just write the sign and any real parser would actually fail. Now that would be funny.

  • (cs) in reply to jmucchiello
    jmucchiello:
    lolwtf:
    "I'm sure he meant winker. Someone who winks.

    Well you can't keep a winker on staff. Eventually he'll wink at the wrong person and your company ends up caught in a sexual harassment suit.

    Same if you keep a wanker.

  • ath (unregistered) in reply to one in the gray mass
    one in the gray mass:
    Who did make You the Gods of coding? No one borns knowing everything, the things are learnt through practice usually. What would be Your actions if You were asked to (1) perform a brain surgery on an open road having all the tools needed, or (2) simply make a fire in a wood having no matches, no lighter, no nothing, only wood?

    I'm not saying that the code is bad (although it can be different). But what rights do You have to blame someone for writing such code?

    Personally, I think XML and all the 'tagged' pseudo languages are unnecessary, usually or even in all the cases there is better data format for that specific problem. But current trends force You to use XML and it's parsers everywhere and everytime You have to store or retrieve data - even if it's only a few characters. The tags itself take up more space than the actual data. See the XML for Yourself.

    Welcome back Topcod3r! Haven't seen you for a while.

  • one in the gray mass (unregistered) in reply to ath

    Actually, I participate in TopCoder competitions. But still, I am not convinced, that XML is a panacea for all programming problems

  • imu (unregistered) in reply to netjeff
    netjeff:
    Code Dependent:
    Someone else:
    What would you do if someone asked you a rhetorical question?
    Give a rhetorical answer.

    My favorite of these type:

    If I were to ask you this question, what would your answer be?

    Is that a hypothetical rhetorical question?

  • Anonymous (unregistered) in reply to one in the gray mass
    one in the gray mass:
    Actually, I participate in TopCoder competitions. But still, I am not convinced, that XML is a panacea for all programming problems
    And when exactly did anyone suggested that XML was a "pancea for all programming problems", except you just then? This is clearly a battle that you have royally lost, it's best you just slink off to the next article nice and quietly...
  • sagaciter (unregistered) in reply to Waratah
    Waratah:
    I worked with a programmer that did not want to learn how to use a csv library or an xml library, far easier to write code like this. He was the senior programmer in the area.

    Oh yes and he wrote code like this:

    for( int i = 0; array[i] != 0x20 ) { word[i] = array[i]; }

    His code didn't compile?

  • ullamcorper (unregistered) in reply to OzPeter
    OzPeter:
    fw:
    Dan:
    It's not even a WTF. It's an FTW. Fire-That-Wannabe.

    W*nker more like

    WTF? who did you think you were going to offend by leaving out the "a"? And given a choice of 5 potential vowels to insert, how stupid do you think people have to be to not find the correct vowel?

    Only 5? What language is that?

  • validus (unregistered) in reply to bob
    bob:
    Hoodaticus:
    bob:
    Jebus, what a bunch of obnoxious, arrogant dweebs you all appear to be.
    Did we insult your kode or something? Do YOU parse XML with nothing but wood as well?

    CAPTCHA: plaga - a disease-infested beach

    nope, i don't even work in this profession, just thought it needed saying.

    Umm.. WTF?

    Jebus, what a bunch of obnoxious, arrogant dweeb you appear to be.

  • I am paratus (unregistered) in reply to netjeff
    netjeff:
    If I were to ask you this question, what would your answer be?
    There is no question there.
  • decet (unregistered) in reply to Steve the Cynic
    Steve the Cynic:
    But you don't have any string, rawhide cord, etc. You just have wood. Um, er, let me rephrase that. You just have pieces of wood.
    That's a bit too homoerotic for my taste.
  • 无名氏的很好的理由 (unregistered) in reply to Gregoire

    According to Google, the Chinese for WTF is 什么他妈的.

    (Wait for it... wait for it... and TDWTF is now banned in China.)

  • (cs) in reply to chrismcb
    chrismcb:
    He used the xml doc object module. Got a list of children and said "size = node.child[0].value" and "type = node.child[1].value." Sort of completely ignoring the names, and just hoping that they would also be generated in the same order (and that the parser returns them in the order generated)
    Assuming that you're generating XML that matches a schema that's using an xs:sequence (a very common case where people bother to codify their document formats at all; you don't mention whether you've done it properly or hacked something ad hoc together) at that point then your coworker was correct. Ill advised perhaps — depends on situational constraints that I have no access to — but still definitely correct.

    Now if he'd been depending on the order of attributes within a single node, that would be a really deep WTF…

  • lucy (unregistered) in reply to AdT

    Yes, hungarian notation, especially the systems variant is bad and ugly; as it doesn't carry semantic information. If you need to use it, you're not naming your identifiers well.

    Better:

    input = inputbuffer;
    output = outputbuffer;
    for(remaining = size; remaining; --remaining)
        *output = *input;
    
  • AdT (unregistered) in reply to swordfishBob
    RogerC:
    Do you have something against memcpy?

    No, that was just an example. :)

    swordfishBob:
    That's a bit wasteful.. why not post-decrement the remaining bytes in the comparison clause?

    Good point! Maybe I even did this. There are many interesting uses of C++ operators by the way. For example, the following five statements can be combined into one.

    if (performOperation)
    {
      status = operation();
      if (status.succeeded())
        successNotification(status);
      else
        failureNotification(status);
    }
    
    performOperation && (status = operation(),
      (status.succeeded() ? successNotification : failureNotification)(status),
      true);
    
    swordfishBob:
    Did you really prefix counters with "sz"?

    No, that's for self-anonymization...

  • methinks (unregistered) in reply to Waratah
    Waratah:
    I worked with a programmer that did not want to learn how to use a csv library or an xml library, far easier to write code like this. He was the senior programmer in the area.

    Oh yes and he wrote code like this:

    for( int i = 0; array[i] != 0x20 ) { word[i] = array[i]; }

    You may want to optimize this:

    word[0] = array[0]; for(;;)

    This makes the infinite loop faster and protects word[0] from being worn out because it's overwritten incessantly... and moreover you save on a variable ("i")!

  • methinks (unregistered) in reply to ath
    one in the gray mass:
    (...) Personally, I think XML and all the 'tagged' pseudo languages are unnecessary, usually or even in all the cases there is better data format for that specific problem. But current trends force You to use XML and it's parsers everywhere and everytime You have to store or retrieve data - even if it's only a few characters. The tags itself take up more space than the actual data. See the XML for Yourself.

    You'd better stay "in the gray mass"...

  • (cs) in reply to OzPeter
    OzPeter:
    fw:
    Dan:
    It's not even a WTF. It's an FTW. Fire-That-Wannabe.

    W*nker more like

    WTF? who did you think you were going to offend by leaving out the "a"? And given a choice of 5 potential vowels to insert, how stupid do you think people have to be to not find the correct vowel?

    He did it so that I could still read it at work despite a stupid web filter.

  • SR (unregistered) in reply to ullamcorper
    ullamcorper:
    OzPeter:
    fw:
    Dan:
    It's not even a WTF. It's an FTW. Fire-That-Wannabe.

    W*nker more like

    WTF? who did you think you were going to offend by leaving out the "a"? And given a choice of 5 potential vowels to insert, how stupid do you think people have to be to not find the correct vowel?

    Only 5? What language is that?

    English has only 5 vowels. I'd guess at English.

  • JayC (unregistered) in reply to SR
    SR:
    ullamcorper:
    OzPeter:
    fw:
    Dan:
    It's not even a WTF. It's an FTW. Fire-That-Wannabe.

    W*nker more like

    WTF? who did you think you were going to offend by leaving out the "a"? And given a choice of 5 potential vowels to insert, how stupid do you think people have to be to not find the correct vowel?

    Only 5? What language is that?

    English has only 5 vowels. I'd guess at English.

    Wylie E. Coyote begs to differ.

  • (cs) in reply to SR
    SR:
    English has only 5 vowels.
    Plus ‘y’ in some situations. And often there are many vowels encoded with one letter. But it's really so simple…
  • fcuktrad (unregistered) in reply to methinks
    methinks:
    Waratah:
    I worked with a programmer that did not want to learn how to use a csv library or an xml library, far easier to write code like this. He was the senior programmer in the area.

    Oh yes and he wrote code like this:

    for( int i = 0; array[i] != 0x20 ) { word[i] = array[i]; }

    You may want to optimize this:

    word[0] = array[0]; for(;;)

    This makes the infinite loop faster and protects word[0] from being worn out because it's overwritten incessantly... and moreover you save on a variable ("i")!

    labela: asm { jmp labela; }

  • KSB (unregistered)

    For the last month or so, we have had this topic in our irc channel;

    14:32 -!- Topic for #someproject: Reimplementing Someproject: < somenewdeveloper> i'm not terribly worried, i mean the protocol is xml-based, how difficult can it be?

  • Steve the Cynic (unregistered) in reply to AdT
    AdT:
    performOperation && (status = operation(),
      (status.succeeded() ? successNotification : failureNotification)(status),
      true);
    

    Yer a sick pup. Maybe you need to locked away somewhere with the guy with the (pieces of) wood.

    AdT:
    swordfishBob:
    Did you really prefix counters with "sz"?

    No, that's for self-anonymization...

    Or self-(something else)ation?

  • Julia (unregistered) in reply to Calm Mint
    Calm Mint:
    This type of WTF is so common we need a new name for it.

    Since "XML" stands for Extensible Markup Language, let us consider what's going on here. First, it is not a Language, because they are parsing column positions as if it were an old-school COBOL record. Second, it is not Markup, because the markup is being completely ignored. And most obviously it is not Extensible.

    XML-- ?

  • PRMan (unregistered)

    I was working in a COBOL shop once where they were complaining that the company sending the XML was a bunch of liars because they said they hadn't changed the format of the XML when they had.

    It turns out both were right. It had gone from a bandwidth-optimized single-line XML to a pretty-printed XML, but the files were identical from an XML perspective.

    30 hours later, the COBOL programmer was able to fix it. Until the next time it "didn't change".

  • homer (unregistered)

    how exactly is this reading xml if its just doing loads of substrings on the same line? I dont get it?

  • Smart Ass (unregistered) in reply to SR

    Actually, Y is a vowel. And sometimes even W may be a vowel, although that's mostly just for words that we've ahem borrowed, yeah that's it borrowed, from other languages.

  • developer001 (unregistered) in reply to Cas

    And have you measured speed of processing the file using XML DOM? I think previous solution was made due to performance reasons. I'm sure performance has significally decreased after you rewritten the code in that way. Almost you've got no benefit from your "correct" way of parsing the file.

  • Ouch! (unregistered) in reply to developer001
    developer001:
    And have you measured speed of processing the file using XML DOM? I think previous solution was made due to performance reasons. I'm sure performance has significally decreased after you rewritten the code in that way. Almost you've got no benefit from your "correct" way of parsing the file.
    Stability with regards to layout changes is no benefit?
  • Wayne (unregistered)

    I got handed a project to optimize where the previous developer had done the exact same thing, treated the XML file as a regular ASCII text file. Guess what the first thing I optimized was?

  • LO (unregistered)

    That remembers me a recent story from one of my Java dedicated fellows.

    He has been creating as a consultant some kind of tool that was to generate some kind of reports into simple XML format. Sounded easy - not until he send them tool to generate reports and they tried to import results into their system.

    "Your XML has wrong format" - he was told. - "It appears that you put TAGS in the WRONG ORDER!".

    I passed...

  • Anonymous (unregistered)

    Don't worry. I'm sure the functions are all secretly overloaded anyway to properly use XML DOM.

  • What the? (unregistered) in reply to Anonymous
    Anonymous:
    Don't worry. I'm sure the functions are all secretly overloaded anyway to properly use XML DOM.

    ROFLMAO

  • your mom (unregistered)

    Sh!t dude... that's nothing. I've seen that same cr@p done in sql. SubString like a mutha!

  • Jim G (unregistered) in reply to wee

    What I see here is a column-conscious legacy data file that's been wrapped in XML, probably a CDATA -- although it's hard to tell, not knowing what's in FindHeaderString(). The various fields are too close together for them to be individually tagged XML. Because it's not tagged internally, and column-conscious, how else to parse it? Sure, it might be better to parse out the items and put them individually into the XML upstream from this code, but that's not the fault of this code.

  • Hoodaticus (unregistered) in reply to Jim G
    Jim G:
    What I see here is a column-conscious legacy data file that's been wrapped in XML, probably a CDATA -- although it's hard to tell, not knowing what's in FindHeaderString(). The various fields are too close together for them to be individually tagged XML. Because it's not tagged internally, and column-conscious, how else to parse it? Sure, it might be better to parse out the items and put them individually into the XML upstream from this code, but that's not the fault of this code.

    Why not use DOM to fetch the cdata node before you substring parse?

  • Hoodaticus (unregistered) in reply to Jim G
    Jim G:
    What I see here is a column-conscious legacy data file that's been wrapped in XML, probably a CDATA -- although it's hard to tell, not knowing what's in FindHeaderString(). The various fields are too close together for them to be individually tagged XML. Because it's not tagged internally, and column-conscious, how else to parse it? Sure, it might be better to parse out the items and put them individually into the XML upstream from this code, but that's not the fault of this code.

    Why not use DOM to fetch the cdata node before you substring parse?

  • Phil (OP) (unregistered)

    Always nice too see that the flat file society is growing See my submissions: thedailywtf.com/forums/53714/ShowPost.aspx thedailywtf.com/forums/39000/ShowPost.aspx :-)

Leave a comment on “What Could Be Easier Than XML?”

Log In or post as a guest

Replying to comment #:

« Return to Article