- 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
Ugh!
Admin
The real WTF here, is why didn't he use a hash instead of an array?
vc
Admin
When I read this, I felt like the loud person yelling at the horror movie: "Get the hell outta there! You're gonna die!"
Then I saw my worst fears confirmed.
Admin
I knew arrays were evil.
Admin
That's awesome. I saw something very similar to that about a week ago in the wild during a consulting gig. Scary that is probably very prevalent.
Admin
About a week ago one day I was pondering the zen-ness of an .asp that modified itself. This is close. But to achieve ultimate zen, the core functions would have to be in the same page as products.asp. Until then, I must go ponder...after all...what is the sound of one asp page rewriting itself?
Admin
It's not the tool - it's the person. Guns don't kill people. People kill people.
Sincerely,
Richard Nixon
Admin
Sadly there really are people in this industry who are so wrong that it actually isn't possible to help them. I mean way far out down "Wrong Road" that a journey to go and reach them would take an entire lifetime!
It makes me tired just thinking about it...
This has conjured up some horrific memories from my past - I think I'll join Steve at the bar...
Admin
"No - Bullets Kill People" - Sledgehammer [:P]
Admin
I dunno if you've ever messed around with VB's Scripting.Dictionary object (afaik the easiest (only?) way to do hashes in VB), but they are extremely annoying to work with. Massive bugs can occur because you fail to use cStr around either a key or a data item. Just last week I was having a problem where I was getting data out of the hash that I had never put in. Worse, if I tried to use certain keys to access the data the page would error out. It turns out that the problem was that I didn't cast the data as cStr before putting it in the dictionary.
Now, I know you were probably joking about using hashes given the tell-tale "The real WTF here is...", but I just wanted to use this opportunity to bitch about hashes in VB without being entirely off-topic.
Admin
Hey why not! OK its certainly a WTF but I don't think anywhere near as bad as some of the mind numbing horror that you will see on this site on occasion.
Basically what he's doing is writing an in-memory database. If he was looking for a .NET equivalent, he may, yeah have to use some of those 'Class' things but for the rest of it maybe the closest equivalent would be Bamboo Prevaylance.
Whacky, and obviously not a programmer but there is something appealing about it I'm sure.
As someone said, the real wtf is that he was not using a hashtable, or should i say, Scripting.Dictionary
Admin
This is superior to a flat file storage scheme... how?
Admin
I would have stored it in XML. :grin:
Admin
I think I would have taken the job. It would have taken 5 minutes to write the whole array to a database and then you could junk the include file.
Admin
As rabidly anti-xml as some people on this site can be, I don't think anyone would prefer the wtf's method to xml.
Admin
Wait til the programmer discovers the wonders of reflection. Makes me shudder just thinking about it.
Admin
Good point. I mean, it's horribly, horribly wrong -- but it's at least consistent in its wrongness.
Re: Dictionary; yeah, I think I played with that once. But this is why I use hard drugs and alcohol. To forget VBXXX. I am a quintessential coder burn-out; I refuse to write in anything but ruby these days.
Parent company in conference call this morning: "How possible would it be to implement this webservice client in Java instead of Ruby?"
Me: "Not at all."
vc
Admin
Now we are getting into true Zen-ness. Self modifying ASP.NET code based on self reflection....
....
....
... probably safer not to try, given the current implentation.
Admin
My VB array knowledge is a little rusty but how does Dim STORRAY_Products(487, 4)
allow STORRAY_Products(14,7)? Isn't that a 487x4 item array? Isn't the valid range of indexes for the second dimension 1 to 4?
I can't believe a company with that kind of rinky dink website can afford a consultant.
Admin
A giant sucking sound, to be sure.
Admin
I've used solutions like this where part of the spec is that no flavor of SQL is available, and there's a need to store complex sets of data in files. He at least abstracted maintenance into a single, uniform method!
So, really, what's the WTF? Please explain. No, I'm not satisfied with "ooh, the eyes!", either.
Yes, you end up with limits on storage size, and SQL is the preferred choice. But, with the limitations mentioned above, what's the "non-WTF" answer to this kind of problem?
Seems to me that the WTF here is a programmer unable to challenge himself, and perhaps too dependent on alcohol.
Admin
In this case, I think the person *is* a tool (and not a very sharp one either).
Admin
I dont know. I just feel so sure that there has to be some kind of...i dunno...awesome application for self-rewriting asp files. I just can't think of it yet.
Of course this is coming from the same person who couldn't stop laughing for 5 minutes after thinking about the idea of pcAnywhere'ing into a remote box, then pcAnywhere'ing back into my own box. Speaking of which, I need to try that sometime.
Admin
And the difference between this and an XML "database" is....
...
...
Admin
Good question. I thought that maybe ASP/VB might allow you to run runshod over the original Dim, but that's not true. Then I thought maybe the array was ReDimmed somewhere in the snipped portion, and I tried it - but got this:
<FONT face="Courier New">Error Type:
Microsoft VBScript runtime (0x800A000A)
This array is fixed or temporarily locked
/test.asp, line 12</FONT>
<FONT face=Arial>So, I dunno.</FONT>
<FONT face=Arial></FONT>
Admin
I'd love to see the MythBusters episode on this one ...
Seriously, though, I'm an Knife user, which pretty much does everything I need to do (its handling of hash is exceptional), so I've never had a reason to try Gun. But I do recall seeing this discussed on a forum and from what I recall, Gun is a trigger-driven system that delivers unique "message/object" modules called "Bullets", and it requires an actor (person) to initiate the message/object delivery action. So I think that you're *both* right, to a certain extent.
People kill people ... guns just improve their performance.
Admin
Anonymization error (the original Array had 5 elements) -- I've fixed it.
Admin
I put together something like this for an e-commerce site that "couldn't afford database hosting" and "only had a few products"...Though my implementation didn't include the brillant "core" functionality, I thought it was perfectly acceptable on a small scale. The biggest drawback, of course, is performance, but I let them know that up front, and explained to them what they were going to get, and how it was going to work. Then I wrote a method that hooked my e-commerce frontend onto an array-based flat database on the backend, pocketed my check, tipped my hat, and never gave them another thought.
They called me when the array-based datafile started throwing errors, probably about a year and a half later. I couldn't believe they were still using it...I figured at the time that either they'd succeed, and upgrade, or fail, and scrap it. I told 'em that they just had to delete a few old products, and the errors would go away, because that the code was only designed to hold a few hundred items.
Actual quote: "But it didn't start giving us problems until we got over a thousand" Damn thing had actually held together until the quota'd drive space on their webhost gave out (was mostly the picture, not my file). Yay multiple redundancy.
Talked 'em into going with a database, exported the junk out of the poor flat datafile, gave 'em a free upgrade to the new e-commerce package (which was the same code, tightened up, with 2 new features, and a snazzy new interface), pocketed my check, tipped my hat, and haven't heard from them since. Hopefully they'll complain to their webhost next time.
Just goes to show, sometimes the wierd stuff you find in the field wasn't so weird, initially.
Admin
Alright, how about:
The *real* WTF here is that guy thinks his solution is better than a database.
He was not restricted from using SQL, as far as we know.
Admin
XML == Sexy && Arrays == Ugly.
Or
60 jilluion tags would massively increase performance of your layered, portable app.
Or
If you put this in XML, you'd be able to get another job, later.
Admin
Maybe it was a draw when they tried to agree on a database platform.
Actually the file technique is fine (AS A TOY).
Admin
my first assumption was that this site was the built over time. At the start they had a few products and this worked well. After time the web master began to complain and 'master programmer' came up with brillant method of adding to the 'database'.
Anyways, if I was told to design a datadriven site without any sql flavour, unless it was choice of not eating this week I think I would balk at the assignment.
later,
Admin
Speaking of in memory databases, a company I worked for thought that preloading 30 days worth of applications and persisting them as a dataset on a shared session server (asp.net) would save tons of time when people are viewing the content.
Pity for the poor guy who was the first to access the application each day, his request would usually time out before he got a response.
Add to this the wonderful consequence of having to update the db and dataset every time something changed.
The problems people create trying to avoid problems they should fix are usually worse.
Admin
I love it when people jump to call whatever set of functions they're working on "An Engine."
/joins steve @ the bar
Admin
Half the WTFs that show up here can be turned into reasonable solutions by invoking the proper combination of assumptions regarding the design - some more far-fetched than others.
I've used (and dealt with others') solutions like this, too, under similar restrictions, and have no problem with them as such. No WTF there.
And now, admittedly, this is a subjective description of the events, and certain aspects may be exaggerated for effect. But one WTF given these factors is the original developer's attitude about the solution; most of us here would soberly explain *why* we chose this solution while describing it, not "gleefully" expound on its "beauty".
Another WTF is Steve's reaction - if this represents a "tough, gawd-I-need-a-drink problem" for him, he needs to rethink his career.
And yet another WTF is my taking the time to respond to an AA killjoy's "I'm so tough" post ...
Admin
Anyway, if this guy likes arrays so much, he could have tried serializing the array data to a file. Simpler than XML and requires no DB
Admin
Woah! Isn't that starting to get a little too deep for these forums? "I changed myself, based on some self-reflecting..."
As for the code... I can almost forgive the original programmer. The solution is simple, and it works... so long as you don't have to worry about concurrency issues (which for a web application means all the time).
Admin
Another programmer heading for death row....
Admin
I guess this wasn't designed to work on a webfarm. It would have been fun trying to keep all the files in sync.
Also it's a good idea to keep volumes of static data in ASP files: since the weberserver has to parse them over and over, it keeps the data from degrading when cosmic rays bombard the magnetic media.
Admin
Have you found out why SQL was not an acceptable solution in those cases?
The "programmer" in this case was proud of the fact that he was doing all this stuff without a database. It makes he sound like he could have used one but for whatever reason (maybe to save money) decided to come up with this cockamaney method.
Give us a real life example of where a database cannot be used and then we can discuss the best answer to the problem without using a database.
Admin
I rather agree with you. The main problem this has is the lack of a decent way to query it. But that may not have been important for the application. Given the size of the table, I'm guessing it probably isn't.
One thing you could do if you wanted to wow the original programmer and lead him to a better way of thinking is to change the code so it automatically loaded the array from a real database at startup. Then no self-modifying code would be needed to maintain it. I have, in fact, seen some important small domain tables in larger setups handled in just this fashion. And it would be a way for the original programmer to get his feet wet with a real database without having to plunge in head-first.
I truly don't think this is so bad. But, the original programmer clearly needs to lose the fear of complex database tools that inspired him to write this in the first place.
Admin
Yeah, there really are only a handful of WTFs that I've seen so far on this site that I wouldn't want to touch no matter how much I got paid.
There's the hotel reservation system, and there's one that is the database full of databases and one more which was some kind of delphi system.
So, only about 4 or 5 real nightmares. The rest could be dealt with effectively by an intelligent programmer who's willing to roll up his/her sleeves and work it out.
Admin
It seems there is another one, as the Ryobi info seems to override the Dewalt one... (index 345 used instead of 2)
Admin
Why have a program when you can have a "technology"?
Everything being strings means no worries about different types (unless you want to do something with the data).
Sincerely,
Gene Wirchenko
Admin
In the first place, someone who can't be bothered to learn SQL should have never been allowed to code web applications. That's specially true for someone who apparently never heard words like "maintainability", "scalability" or "thread safety".
Admin
Absolutely... any votes for the best misuse of this term folks?
I was thinking of patenting my new "boolTri" technology... it leverages legacy ideal logic to interface tri-state values to 7GL languages, in a nutshell, adds "fileNotFound" to boolean values...
Of course this opens the door for new "Capitalist" technologies such as paulaBean and IneedToKnowHowToUseUnderscores.
Admin
I would go for 'descriptiveCSS', the technology that tells you the style of a class in its own name! As well as making coding simple, it tells future maintainers what you intended the code to look like. The perfect way to make your legacy live on.
Admin
/Code/.../Data/
That's just something you don't really want to see in a directory structure.
Admin
Any industry rag's ads?
There are no bonus points for using the words "finally" or "solution" in your answer.
Sincerely,
Gene Wirchenko
Admin
I think you can easily make the case that there are some WTFs - including ones that are driven by 'requirements' or constraints as mentioned above - that can very clearly indicate to you the culture and caliber of the people you're dealing with. If you use a sufficiently generous definition of "no matter how much" then I agree, there's little here I wouldn't dive into for an insane amount of money. However my experience has been that the most esoteric and/or offensive WTFs always seem to come along with average to low compensation, not high. So long as I have a choice in what I do I'll be doing it where there's a minimum of idiots and jackasses.