- 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
Cool infinite loop, bro.
Admin
"When I looked at the two example files, everything was at the same place in both files, so rather than use a long winded method to parse the file I think it would be quicker to write code that just grabbed the needed parts directly from the file. After all, the positions in the file are hardly likely to change and the documentation will also state that they should never change. "
:-)
Admin
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.
Admin
I can't help but wonder if someone told the programmer, "XML is the latest and greatest thing! We must use XML for all future data storage and interchange!" And the programmer said, "Umm, okay. Can you give me an example of one of these XML files? Oh, I see. Okay, I can create a file that looks like that and read it back, sure." And never bothered to ask why he was doing this or what the advantage was supposed to be, nevermind how to do it right.
Admin
Admin
Probably the project originally had a perfectly adequate import method using fixed-length fields.
Then XML was invented, and since no IT manager on the planet knows what the hell it is for, they all decided to use it for everything. So, the export format was changed to XML to make it better. Because it's, you know, better. So, the techs wrote the XML export function, then tweaked it to make the data columns line up reliably to minimize the impact on the already working import code.
But they didn't document it, because a manager might read the documentation, and discover the ruse.
-Harrow.
Admin
Admin
-Harrow.
Admin
Please don't make excuses for that code, or the lack of thought/ignorance which produced it. Second, don't trot out some "XML is always bad" strawman based on your anecdotal experience. (Yes, I have seen XML files in which the tags themselves are a relatively small proportion of the total "characters" in the file.)
The guy is tasked with reading in XML data, and is either too stupid or too ignorant to take advantage of XML's fundamental qualities. He's treating that file as if it's a fixed length record type of thing, which it most certainly isn't. In short, he's banking that neither the length of the tags or the length of the data will EVER CHANGE. Throw out the XML and can't you see how that would be a terrible idea for almost any type of data storage format?
What this guy is doing is essentially the same thing as creating an ASCII dump of a relational DB, hoping that the output is always the same, and parsing through the dump as a text file in order to match up DB records based on column position of the data he needs. You might think that's a stupid example, but I have personally seen someone do just that. It was every bit as screwed up as what this guy is doing, and he got schooled. As this guy should be.
There's no need for "Rights". He's using a hammer to drive in a screw, and should have his tools taken away until he knows what each one is for.
Admin
At least the decision here between altering within a bad structure vs. reimplementing correctly is not a tough one.
Admin
[quote user="one in the gray mass" What would be Your actions if You were asked to (1) perform a brain surgery on an open road having all the tools needed[/quote]
This is why unqualified people aren't asked to do brain surgery. This is also why unqualified people shouldn't be asked to write code and why you shouldn't be asked to write analogies.
Admin
It's simple. XML is Chinese for WTF.
Admin
What would you do if someone asked you a rhetorical question?
Admin
Admin
Jebus, what a bunch of obnoxious, arrogant dweebs you all appear to be.
Admin
someone should tell them that XML, like Saxon or DOM, wasn't invented there either.
Admin
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.
Admin
Admin
We were not asked to perform brain surgery, or to start a fire using only wood... we were asked to analyze a function to read an XML file... and if you have even the slightest glimmer of knowledge about XML you would realize OH MY GOD MAKE IT STOP OW OW OWOWOWOW Bluuuuuurgh....
Admin
CAPTCHA: plaga - a disease-infested beach
Admin
nope, i don't even work in this profession, just thought it needed saying.
Admin
Refuse to and find someone actually qualified to do it? Not a brain surgeon or a murderer so not much good I can do by cutting someone’s head open. It’s an amazing concept don’t you think? Refusing to do thing you’re not qualified for and that you’d likely just cause a bigger mess by trying.
See above, granted in this case I’d of course try if my life depended on it.
In general I don’t see ignorance as anything more than an excuse. Have I written atrocious code due to ignorance? Yes. Do I think of myself as an idiot in retrospect for not looking into the problem more so I can write proper code? Yes. Do I try to learn from those mistakes and not repeat them in the future? Yes.
There’s little point in excuses other than to cripple my own future growth and improvement. Likewise I try to avoid getting in situations where I’m doing more damage than good. My ego isn’t such a fragile little thing that acknowledging my own deficiencies would cause me to fall into a decades long depression.
Admin
We're not arrogant. We all really can write much better code than the sample. I did just six hours ago.
This site is the America's Funniest Home Videos of code. Excuuuuse us for laughing.
Admin
Brain surgery for amateurs
Admin
You must be new here.
Admin
Oops, looks like I must be new here, too.
Admin
My favorite of these type:
If I were to ask you this question, what would your answer be?
Admin
Has anyone considered the possibility that "one in the gray mass" is trolling? Seems pretty obvious to me...
Admin
Admin
When he tried it on me, my immediate answer was, "Red."
Admin
You missed your chance! You could have typed Run, First, run! :P
Admin
I propose that from now on, XML used in this context should stand for Excruciatingly Malformed Litter.
Admin
Change the "e" word back to extensible and I think it's perfect!
Admin
This is some truly inspired foolishness. I mean, who would even think of doing it this way, much less actually going so far as to implement it?
Admin
You've got an excellent point! Just the other day I was strolling on the open road, and someone ran up to me with a Macbook. He was screaming incoherent jibberish and we walked to a Starbucks. After I dosed the Apple fanboy with a latte, he calmed down a little (well, maybe he didn't calm down that much), but at least he was speaking something that resembled English.
He insisted that we walk back to the point where we met, and that I write an XML parser by hand, right there on the open road, even though I've never used a computer in my life. I told him I'd give it my best shot, if he employed me to work for him full-time + benefits and make my official job title "Software Engineer V".
He negotiated for "Programmer V" and shitty dental, and I agreed.
Thus an XML parser you've never heard of was born. Hell, I'm a Programmer V .. what right do you have to criticize my parser, you arrogant bastards!?!
Admin
The funniest thing is wondering what went through the original programmer's head. In my mind, she sat down, opened the XML file, thought "hmm, it's a text file with the values stuck between these fixed-length strings, I could parse this using substrings" and straight away got down to counting characters. Or maybe looking up how to get substrings, then counting stuff. And, when she finished, she sat down and thought, "wow, I'm such a good programmer! That was pretty complicated!"
The next bit of fun is trying to imagine what I'd do if I got there in time to stop her from doing this bad, bad thing. Or maybe immediately afterwards. I like to imagine that her eyes would pop and she'd become a passionate XML advocate, instead of wondering why they didn't just use a CSV.
Admin
Deserves to be the featured comment.
Admin
I've done this sort of thing, and I'd do it again. In the right situation. The right situation, means I own the producer and the primary consumer. Secondary consumers can parse the xml, but the primary parses the lines.
Admin
My guess is, someone was advanced enough to know to use Notepad for actual file content. Or maybe her supervisor, after she ran to him hollering that the "parser" wouldn't work, pointed out at the error with using IE. Then no thought had occured to the supervisor, like, 'heck, WTF is she having problems with?' No proper code review had followed the incident. But profit was made, so who cares...
Admin
Reminds me of my last project... Fortunately I fixed the code before it went into production, but my coworker tried to parse some xml.
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)
Admin
There was a time when I would have agreed with you. But how long will you own both the producer and the consumer? What happens a year from now when you leave and one person takes over the producer and someone else takes over the consumer?
Or when someone decides to add a bunch of stuff to the XML? Now you have to rewrite BOTH the producer and the consumer, instead of just the producer.
Admin
This explains your lack of understanding. Please allow me to translate the WTF at the top into your esteemed profession.
A customer places an order. Your colleague asks "would you like fries with that" and upon an affirmative response sets the customer alight in several places.
Admin
The trick is to specify the use of -very- well-formed XML instead of regular well-formed XML. With plain-vanilla well-formed XML, you have to use one of those elaborate and complicated DOM or SAX parsers. By specifying the use of -very- well-formed XML, you can parse using much simpler and faster substring extraction.
Has this idea been patented yet?
Admin
Anyone who is thinking who ask themselves two questions 1. What is this XML all about and 2. Surely there is easier way to extract the data. From there they would discover all the joys of XML. Obviously someone wasn't thinking.
Admin
Of course it's unnessesary. XML is for humans, with lots of little redundacies so that we can understand the semantics. Also, with a universal parser and various query tools, you can do so many things only dreamable (practically), unless you have readily available parse tree representation of the dialect of your choice.
The choice to "parse" XML this way is inexcusable. This is not parsing. There are no sanity checks. XML need not have to create a DOM to be parsed. A low level XML parser should be highly efficient and yet still recognize bogus data. With this WTF, unless one knew the nonsense going on behind the scenes, all matter of erroneous matters could occurr, and you woud quite possibly never know. After all, most people would assume that no data representation problems would occur in changing a value of an attribute or a node of freaking XML document! If you are going to use a fixed width data representation, don't dress your data as something it isn't.
Admin
Admin
Admin
Reminds me of my current project. But it's not the guy's fault... it's because we didn't specify that the caller might not always send the same xml file with the exact same values...
And anyway, he explained that the parser was bugged. Sometimes for empty values the output was malformed. Something like "<elem/>" instead of "<elem></elem>". Gosh, how come these java guys never noticed that bug!?! lol...
Admin
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.
Admin
That is what happens when you have people that are proud of their line of work see what some scrub managed to barely get working. In a very ugly and bad way.
Some things deserve to be hung out for public ridicule. This is one of them.