- 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
So their database is an ASCII text file? Run, Forest, run!
Admin
1st?
Admin
ehm, not really :)
Admin
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.
So after we cross out the things it's not, we're left with "---". Kinda like C++, but headed in the opposite direction. Or maybe "XXX", as in, children under 18 should not be allowed to see this stuff lest it permanently traumatize and scar their impressionable minds.
Admin
It's an "optimization." Much faster to read by data position than to parse.
Admin
From: JT Klopcic To: HR
It has become necessary to contact the programmer that is responsible for project xyz. Due to the nature of this project it is imperative that I have his home address as opposed to merely a phone number or an email.
On a separate note, I'd like to ask whether it would be ok if I borrowed a knife from the kitchen.
Thank you
Admin
Admin
That's some double-plus-wtf?!
Admin
Oh, no - the horror. I got about half way through, then realised what was going on.
The worst thing?
I did this once.
Then I realised, ripped it up and reimplemented it using XML DOM.
Admin
Nonextensible Markup Language, obviously
Admin
man "root of all evil" ( http://pplab.snu.ac.kr/courses/adv_pl05/papers/p261-knuth.pdf )
Admin
It's not even a WTF. It's an FTW. Fire-That-Wannabe.
Admin
Admin
Depending on the sort of system that is being used, the data may actually be STORED by data position. Old school databases used to do it that way, where the "record" would have a length of say, 500 characters. And field_1 would be 0->10, field_2 would be 11->16, etc.
Admin
I err...replied to the wrong message, obviously.
Admin
Admin
Using a non-extensible comment system, obviously.
Admin
Admin
Admin
Admin
Admin
So it's a Non-extensible Non-markup Non-language? That's "NNN".
Admin
W*nker more like
Admin
Admin
Hahahaha... I love the name on those methods! fixABC? WTF? Uh! And method function names that start with a caps, great!
Admin
Now there's an award worthy observation.
Admin
Well, at least it doesn't look like it'd be too hard to replace it with something that uses the XML classes provided by the .NET library.
Admin
Yes, that's the standard in .NET. This is not Java.
Admin
And then their precious database was destroyed by xmllint --format...
What about "ughstensibility"?
Admin
Admin
The REAL WTF is that the coder checks to see if line 2 was properly read, but line one is magically assigned to m_Textline somehow.
Yes, that is far worse than reading columns from an XML file...
Oh never mind.
Admin
:oD
Yikes!
Admin
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]; }
Admin
I noticed that too. Presumably, it's a member variable and is assigned as side effect of:
FindHeaderString(_sr);
Notice also that the coder doesn't check to see if it's null after FindHeaderString (which would be possible if the file was completely empty), nor do they check the lengths of the strings before trying substring.
Admin
This brings back nightmares from my last contract at a large bank. Their inhouse "dsl" was XML based. Sounds good I thought until I got back string out of bounds exceptions etc. Turns out their "parser" was written pretty much like this.
When I asked why they didn't use a proper XML parser, they looked at me like I was from space, their architects has said that this was much faster and more efficient. Why not just use a csv file, guess that wouldn't have been cutting edge enough lol
Admin
100% WIN. I need to save this as a template, would save me a lot of time.
Admin
Quite clearly, this method is reading Positions Of Stream, hence POS. Or perhaps POS Of Stream, for a recursive acronym.
Admin
Admin
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?
Admin
It's overused anyway. ;)
I used to write code like this:
until a University tutor pointed out that for loops were invented to make code more readable.
Admin
Admin
Admin
I nominate "insensibility".
Admin
Winker?
Admin
Um, regex much? A '*' matches the preceding character zero or more times. Maybe something like [aeiou] would match your 5 vowel constraint requirement.
Admin
I did those things to my tutors just to see how badly they could fail me sometimes. ;) Most of the time I just got a chuckle and a pat on the shoulder. But one of them almost turned white, and then bright red and I seriously thought he'd pop an eye or something when he saw it. :) then I showed him my serious code. I think he kindof had it in for me from that point. ;) Code was sacred to him. Best teacher I ever had though.
Admin
That's not XML data... that's data with an XML overhead! Those "tags" are just comments, lol
Admin
"<comment>WTF!?</comment>".substr(9, 5)
I'm sure he meant winker. Someone who winks.Admin
Admin
Especially as memcpy is normally optimized to copy in chunks (e.g. 4 bytes) wherever possible. Though a really good optimiser would be able to replace byte-by-byte copies with a memcpy call.