- 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
The WTF is really because all the structure is magic
want the price for the Black & Decker "Auto Tape Measure" code ATM100
it is STORRAY_Products(14, 5)
so the accessors are all magic
it wouldn't be so impossible to keep the NO SQL part but add significant structure
Class product
Public manufacturer
Public name
Public code
Public image
Public description_html
Public price
Public weight
Public flag
End Class
Dim STORRAY_Products(487)
Set STORRAY_Products(14) = new product
STORRAY_Products(14).manufacturer = "Black & Decker"
STORRAY_Products(14).name = "Auto Tape Measure"
STORRAY_Products(14).code = "ATM100"
STORRAY_Products(14).image = "/products/images/bd_atm100.gif"
STORRAY_Products(14).description_html = "<p>Extend and retract with the push of a button<ul><li>Blade ... "
STORRAY_Products(14).price = "21.99"
STORRAY_Products(14).weight = "2"
STORRAY_Products(14).flag = "True"
So the price for the Black & Decker "Auto Tape Measure" code ATM100 becomes STORRAY_Products(14).price
the only way to search the array is by index so you would have accessor helpers
Public function get_product(manufacturer, code) ' O(n)
For Each p In STORRAY_Products
If isObject(p) Then
If p.manufacturer = manufacturer And p.code = code Then
set get_product = p
Exit Function
End If
End If
Next
End Function
response.write get_product("Black & Decker", "ATM100").price
Admin
No, ammoq, that function only saves the array, it does not generate it (look at the signature for the function - note the array that is being passed in)
Admin
This counts as an attempt to do the wrong (Q&D) thing right. IMO not a good idea.
Eighter keep it quick&dirty, so at least it's as simple as possible; or do the right thing - use a database.
Admin
I battled with the forum s/w that I missed these points
s/STORRAY_Products\(([0-9]+),( +?)5\)/STORRAY_Products(\1).price/g
Admin
Ah, right, that must have been my problem. I was supposed to pass the dictionary object a string, but instead I passed it a string! Ah, that makes so much more sense now. Perfectly clear. Yep. How stupid of me.
VB is supposed to be taking care of casting. And it does perfectly fine when I pass in integers. Yet somehow it arbitrarily needs an explicit cast when I pass in strings. And I'm supposed to somehow magically know that VB isn't going to pass my string into the dictionary object right? If VB is not going to require explicit casts then it damn well better make sure that it knows what to implictly cast as. In this case it obviously doesn't and screws something up. I have no control over what data type VB uses without explicitly casting EVERYTHING. (Even then I don't have full control as VB may perform an implicit cast AFTER my explicit cast, happily routing around what it thinks is an error, regardless of what I really want.) Casting everything by hand is a rediculous waste of space and makes code near unreadable. Instead I have to wait for improper conversions to break my code and then try to fix it.
So let's make a deal. I won't assume that VB is always going to properly cast my variables and you won't assume that everyone else is an idiot and beneath you and your clearly infinite knowledge of using "proper data types." After all you know what they say about assuming. It makes an "ass" out of "u" and ...err...well actually I guess that's all it's doing here. [;)]
Admin
Correct. This is how Product.asp is written. The array is created by including Product.asp into the page (probably every page that needs "access" to the product array).
So the live cycle goes like this:
a) you start with an almost empty Product.asp page:
(To make the example easier, let's assume you can define an array with a size of 0; I don't know if VB allows that)
Then some program accepts user input and adds it to the array. Or it imports some file (CSV, XML, who knows)
at the end, the new array is written back to Products.asp
Function STORRAYLIB_SaveArray("Products", STORRAY_Products);
Repeat that 345 times, and you have the full product database!
Admin
Yes, correct answer (and the beauty of being a consultant). There are so many people in this industry who haven’t a clue about how to design and build software properly. But the unfortunate thing is, these people are often supported by others who do know what they’re doing. This ultimately makes them productive and keeps them in their jobs.
If everyone who was brought in to try to clean up that mess just left as they ought to, the person responsible would eventually be left to deal with it by himself. Ultimately, he is going to reach a certain limit and fail to meet expectations. Soon after, one would hope he would be replaced with someone competent.
Of course, that might just be hopeless optimism for me, especially considering that I have worked with people who have “nine years of experience”, but were utterly clueless when it came to rudimentary topics. Nevertheless, getting up and walking out on this kind of incompetence is a good start.
Admin
My God, man! You'll rip a hole in the fabric of space-time!
Actually, one of my co-workers did something similar. From work, he VNC'd to his Macintosh at home, from which he RDP'd to a virtual machine (on the same box) running Win2k3, from which he RDP'd to a third machine hosted by a friend (the extra step was necessary because he had to copy some files from one machine to the other). Everything was fine until he had to "CTRL-ALT-Del" to log in to the final machine and had a hard time figuring out how to get the command all the way there - both VNC and RDP wanted to intercept it...
Admin
Yeah, I understood all that ammoq, but what I was trying to get at was this:
Then some program accepts user input and adds it to the array. Or it imports some file (CSV, XML, who knows)
Now, I suppose it could have been generated by user input, but I was assuming (wrongly, rightly, I don't know) that it was importing a file. Now, wouldn't it have made more sense to simply use that file rather than write it all to Products.asp? My point was that the data came from somewhere, and we don't know where. Given that, I can't see the reason for this method. To be honest, though, wherever the data came from, chances are that a different method of storing the data could have been found.
Admin
You are ignoring the fact that they were willing to pay an independant consultant to come in and show them how to port it to asp.net. So you're whole Q&D troll argument goes out the window.
Admin
That's not that unusual. If you have many customers, each using a different remote access method (VPN, modem dialup), and many people who might have to do maintenance to all of those customers, you likely end up with one or two "hubs" with all the VPN software installed, modem attached etc; technicians access the customers' sites through the "hubs", because it would be to complicated to install all VPN products on every technician's PC.
Admin
All the benefits of a database, except for atomicity, consistency, isolation, or durability... oh wait...
It looks like Alex left something out here, in between "proclaimed," and "Although".
Admin
I guess they thought porting it to ASP.net would be easy; throw into the automagical converter, push a few buttons and voila - here comes the brand new ASP.net solution. And this is what the consultant could have done:
a) (low budget) serialize/deserialize the array to/from a file, keep the rest. If they were happy with the storray engine, they may alos be happy with the storealize engine.
b) (high budget) do the right thing, use a database
c) (no bonus) insult the customer, run away
Admin
Are you talking about VB or VBScript? It sounds like VBScript, which is very different from VB. In VB you can easily declare data types and all that, but in VBScript the types are hidden from you and often you do require explicit casting. But if you are talking about VBScript, say VBScript.
If you are talking about VB, then I'll need you to submit some sample code showing this behavoir before I can decide wether or not you are "beneath" me .
Admin
Err, yes, VBScript. Generally when I mean VB I specify VB6 or VB.net (depending on which). Since TWTF was in VBScript I assumed (hehe, oops[:$]) people would understand I was speaking from the context of VBScript, not VB6.
Just for further information, the problem apparently (not entirely sure) happens on occasion when I have a line like:
Dict.Add "mykey", RecSet("SomeData")
Where RecSet is an ADODB RecordSet object. The thing is it only happens sometimes. I've used lines like that before no problem, but for some reason on a new page I was writing this problem cropped up.
Admin
This must be how google does it, it explains why they have such fast results. Just one big array of 9.1 billion URLs.
Admin
I've had this problem in VB6 as well. RecSet("SomeData") gets added as some sort of ADO wrapper type instead of the actual field value. When the recordset goes out of scope, you can no longer reference the object stored in the dictionary. I always had to store the rs!field to a local variable and then add it to the collection to get around this. Not sure what causes it either.
Admin
> Dict.Add "mykey", RecSet("SomeData")
> Where RecSet is an ADODB RecordSet object
Hmmm... I have had troubles with ADODB record set value retrieval in VBScript, even without dictionaries.Are you accessing the fields in the same order that they are being returned by the query?
Are there any text/ntext/image fields? (BLOB fields)
Admin
> RecSet("SomeData") gets added as some sort of ADO wrapper type instead of the actual field value.
Ah... try RecSet("SomeData").Value or even CStr(RecSet("SomeData").Value)
Admin
Either way, a variant is returned. You should *always* cast it to String if that it what it is. This is the same as ADO.NET, which returns Objects and all values should be cast as well.
Admin
Now it makes a little more sense. If you didn't repeat the letters "VB" over and over, I probably would have assumed you meant VBScript. Either way, you were complaining about the Dictionary object when the issue you are having is with an ADO Recordset object. The default property returns a VARIANT -- you must cast it to the proper data type. The computer doesn't automatically convert variants to what you think it should be. A single property, in any strongly typed modern language I can think of, cannot sometimes return a string, sometimes an int, sometimes a date from call to call. (without overloads)
Admin
This is what happens when I edit posts ... it *was* in there at some point :-)
Admin
Student: Master, are prolog programs data or code?
Master: Does not Trollable account to us of the many wonders of Lisp, in which code and data are as one?
S: Does that mean that the distinction between data and code is an artifact of the mind?
M: There is no spoon.
S: But surely there is a reason for creating this separation, or it would not have been made?
M: To a bird, a worm is a meal; to a cat, a bird; and when the cat dies, it becomes a meal to worms.
S: So code can be data, and data code?
M: To a compiler, code is data; to a backup utility, a compiler is data; so, you see, everything is data, and everything is code.
S: Right. Screw this Zen shit, I'm joining Steve at the bar ...
M: Mu!
Admin
I have done it with logmein.com through 4 machines...craazzzzzy
Admin
Amen!!!
Admin
*lol* +1 insightfull
Admin
There's an awesome acronym that you should learn, it's called ORM, or Object-Relational Mapper.
It's like, mapping relationalish databases to object, and never manipulate any SQL in your code, only objects, and the ORM engines does it's magic behind the scene.
Not the fastest stuff on earth (unless you go into the ORM engine/objects definition and tweak the queries), but it's Good Enough and it usually Just Works (a very good example of ORM is Ruby's ActiveRecords that you can find in RoR)
SQLite, it's like flat files, but good.
And then there is SQLite, a database-less database for the times when you really can't use a "real" db
Admin
What! JET (aka MS Access to most) should never be used. Rather you should spend thousands on an Oracle server, even if it's one table with 100 records and 3 users. Or conversely use XML as it's far cooler. JET only exists for real developers to sneer at and you should never touch it. Your geek cred will immediately decrease to near zero and chicks won't dig you.
Admin
I haven't been to thedailywtf for a few days, so I figured I'd use this as an opportunity to catch up. After seeing this code, I think I need to find something else to do to take my mind off of it for a while. This is just disturbing.
Admin
Oh, I agree totally, don't do it that way !!
Admin
Ignoring the shamless self-promotion, I did look. And I was horrified. You have to love the use of tables that throw off the entire format. Like the "About" page, where you have a three page column of text 2-3 words wide because of the picture. Beautiful. Now, Mr. Kitzmüller, we require the real name of this "winter_mute" to also avoid in the future.
Oh, and I really love the irony of having an acronym for "quick and dirty."
On topic:
I'm surprised no one has speculated as to how our hero Steve acquired the source code if he left the first and only meeting so promptly.
Admin
Indeed, if it were not for guns we'd just kill people by humping on them with a really cold turkey
Admin
fixed the about page, thanks
Google is your friend.
Admin
I'm afraid that the "About" page is still broken. Basically, it still looks horrible at 800x600, which is why you shouldn't test only your website in your 1024x768 screen :)
What about placing the text and the image in the same cell using floats and also adding some padding or some margin to your cell instead of adding an empty cell to separate things:
And, if your hosting allows you to use some dynamic language, please get rid of frames, by simply using "include file=main.html" from the top of every page. They serve no purpose that I can see and that a dynamic include won't do better (like allowing me to link directly to the about page whithout having to dig into the page source code for the adderess of the inside-of-the-frame page).
Admin
Enric, you are right with everything.
A minimum resolution of 1024x768 is ok in the given context (1280x1024, as before, probably was not).
I'm totally sure it could be made much better by someone who is experienced with the current trends in (X)HTML, CSS, JavaScript etc.
Unfortunately, that someone is not me. I basically stuck with HTML 3.2, because I haven't made reasonably large web -apps for at least 4 years. Plus: the layout of the current "ammoq" homepage wasn't even made by me. It looks mostly OK under reasonable conditions, and it doesn't sell me anything. If it looks horrible on a PocketPC or PSP, I couldn't care less.
The frame thingy is from the so-called "URL kepper", because the web site is hosted in the tiny webspace I got with my internet account (members.chello.at/erich.kitzmueller/...) and I use DomainDirects service to forward "www.ammoq.com" there.
Admin
ROFL, Ah I was still wiping the tears from my eyes, thanks for making them come back again
Admin
Well, don't the latest security issues with WMF say enough? WMF, doc/xls/ppt documents with macro's embedded etc. etc.
Come on, when I get an Access database/program from a customer, I have to click through 3 screens of security warnings of which at least 1 I can't turn off.
Ok maybe these are MS leaks, but I don't know anyone that really likes working with PDF or PostScript files either. What I mean to say I hope that stuff gets replaced ASAP with file/data formats that DO separate all aspects.
Admin
Try "vncviewer localhost" sometime on a machine where loopback connections are enabled. It completely obviates the need for drugs.
Admin
PDF is pure data unless you start putting javascript into it. Postscript on the other hand is pure code. There isn't even such a thing as a font; it's a program that draws bezier curves based on the input data.
I *love* working with postscript and PDF. I have just put the wraps on an in-house project that writes postscript which can be used three ways: send it to the Xerox printer, where all the images are stored on the printer hard drive and are read in at print time (known as "decomposition" in Xerox lingo); view it on screen with Ghostview, where it grabs the images in EPS format from disk; or convert it from postscript to PDF using Ghostscript, and it will not only grab the images in EPS format but will only include each image once, no matter how many pages it appears on it (and these are documents upwards of 20k pages long).
Yes, I take psychotropic medicine.
Admin
That is the big improvment of ASP.NET over ASP; in old ASP, the code and HTML are interwoven into the same file, while in ASP.NET the HTML portion of a page and the code can be completely separated.
Admin
If no one sees the page rewriting itself... does the page truly rewrote itself?
Amen!
Admin
What if another page rewrites the page, is the sound a different one?
Admin
I also like the way the "developer" wanted to port this "technology" to a compiled language.
Admin
Admin
I have seen something similar in programs of one "good" programmer. He wrote using php something like array-to-php serializer :-). In Poland we call such type of People "skilled beast".
Admin
People with guns!
- Freddie Mercury
Admin
You, sir (or Ma'am, as it may be), are a genius.
Admin
That's the right way of doing hashes. Naturally the key is different in object oriented programming if it's int 1 or string "1". It's not the fault of the Dictionary that you assume all keys being strings without you making them so.
Admin
I've done that. Well worth the effort.
Admin
My old roomie and I tried that, using Remote Desktop and VNC between my PC and his Mac. What happens is you get the expected "hall of mirrors" window going on. When you try to move your mouse inside the area of the remote window, it'll instantly snap it back to the top left corner. So it looks cool, but you can't do anything with it.