- 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
Try this article
I remember reading this donkeys ages ago when I had more of an interest in object persistence mechanisms. I think it probably influenced the design decision to add NEWSEQUENTIALID()
Like anything else, it has it's tradeoffs. It trades an increased possibility of key collision for increased performance, but it's not a giant WTF.
Admin
You are correct. The code would do nothing (in either VB 6 or VB.NET).
Admin
Admin
Oregon lipstick shady memorial function disparity reduce mass.
I am under no obligation to abide by your English language conventions.
Admin
For the folks talking about NEWSEQUENTIALID() or its homebrew cousins:
Why even use a GUID in that case? Why not just an integer? I guess I could see Windows registry entries as place, but the "GUIDs" in the article seemed to be for internal use. There's a built-in function for it, though, so it must be somewhat popular.
I'm not trying to be dense. I am honestly curious about this as my experience is limited to simple scripts. It just seems like there's people insisting on GUIDs when they just need numbers.
("jumentum"...your momentum after a jujitsu expert throws you)
Admin
Admin
In certain database situations (replication comes to mind) using a GUID is required by the system. Also if you have multiple environments where data can be created and manually diff'd, using a GUID instead of an index as a primary key removes the need to manage identity ranges between environments. Using NEWSEQUENTIALID() helps improve the performance of these tables using this type of key, while still keeping the chance of key collision acceptably low.
Admin
I worked in a shop once where they had an MSSQL varchar field populated with GUID's. I assumed that they would be right to be loaded into a System.GUID. Wrong, as the application blew up one day and I found out that someone had decided to just change an A for an X in a spreadsheet that was then imported instead of generating a new GUID. (sigh)
Admin
Are you shure you really know what your are talking about? FYI, real sequential UUIDs do not increment in the last part, but in the first one, i.e.:
{D05F2272-A95D-11DD-A71F-000000000084} {D05F2273-A95D-11DD-A71F-000000000084} {D05F2274-A95D-11DD-A71F-000000000084} {D05F2275-A95D-11DD-A71F-000000000084} {D05F2276-A95D-11DD-A71F-000000000084}
I edited the last part, since that would be my network card MAC address. These where generated using UuidCreateSequential.
I am surprised NO ONE else mentioned this little detail.
Admin
newguid = getnewguid (); while (alreadyexists_in_database (newguid)) { // chances of this happening are so small, we won't worry // about this happening more than once. increment_last_letter (newguid); }
And someone coded getnewguid () to return the same one every time. For example, by calling "srand ()" with a random-looking-number.
Admin
I used to work with this code!!!
It's for a point of sale system for cell phone carriers.
If you think this is a WTF you should see the rest of the code...
Admin
Or if you're in a rush, a roundhouse to the uterus might do nicely.
Admin
For some reason this reminds me of the old joke about the restaraunt that was open 24 hours a day, but not all in a row.
Admin
This appears to be the code that they are using for the U.S voting terminals....
Admin
But I would love a ForkIrishGirl function!!! Or, very useful, a CloneIrishGirl.
Admin
In a previous project on which I worked many years ago, after killing all the children I then wrote in a comment that we now had to turn the gun on ourselves..
That of course when deleting a node and all its child nodes.
Admin
assuming IrishGirl inherits from Object, anyway... (did I just objectify Irish Girl? The feminists are gonna lynch me...)
Admin
I do love it when idiots WTF themselves like the moron that wrong this one.
As has been stated, and is know by any REAL programmer, databases are retards and return horrible psudo-GUIDs.
Admin
yay, another reason not to use 8 spaces for a tab (1 indent)....
Admin
Line 1 and 7 is equal!?
Admin
I don't mind the name of the function, but it is similar to this: For i = 1 To 10 i = 0 Next i
i = 0
Admin
{8B6AA623-F413-4A9C-8703-4D76996E32E} appears twice in the top 10 ??
guid are not supposed to be unique ?
Admin
Just for the record, the GUIDs shown were not obfuscated or replaced for the submission. The WTF was not that they were sequential, but that a) they were stored in a textual field in the database, and b) someone with access to that database -- almost certainly a programmer -- had manually created a bunch of new records with mathematically-impossible GUID values.
As for KillTheChildren, it does nothing at all because the 'For Each' loop "control" variable is just a copy of an element from the collection. It is roughly equivalent to this:
Its author had intended it to set all of the references in the collection to 'Nothing' references (remember that VB6 is really a COM development tool and COM is reference-counted -- setting these references to 'Nothing' decreases the reference counts of the referred-to objects, possibly resulting in their deallocation). KillTheChildren was called as part of the teardown of a form or object. In most places, it also included a:
...after the loop, which does actually release the references, but one place I found omitted that line, so the function had literally no effect. Of course, the entire function's existence was a WTF because when a Form is "Unload"ed or a Class "Terminate"d in VB6, the local variables are freed. VB6 ensures this is done correctly, so all references to other objects get released pretty much right after KillTheChildren returns.And as for the big series of 'If' statements, it was pointed out that VB contains "AndThen" and "OrElse" operators -- these exist only in VB.NET, and this code is VB6 code, so that method of shortcircuiting isn't available. The "Select Case False" method would have been available, but geeze, that's even dirtier than the nesting of the Ifs!
The code featured here is almost end-of-life now, fortunately. :-)
Admin
Actually, you mean 2^126, because of the variant field (section 4.1.1 of RFC 4122).