• Dr_Barnowl (unregistered)

    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.

  • Matthew Wills (unregistered) in reply to Simon
    Simon:
    I don't think the loop inside KillTheChildren actually does anything, since objIntegrationAccount is just a local variable (i.e., a copy of the reference inside the enumeration)...?

    You are correct. The code would do nothing (in either VB 6 or VB.NET).

  • JimBob (unregistered) in reply to Matt.C
    Matt.C:
    ha:
    I have used phrases about killing the children a few times while solving mathematical problems in graph theory about trees. I stopped do so when my friend noticed that we are talking quite loudly about this on the street and others can hear us.

    Why?

    It's called functioning as part of a society. You should try it sometime.

  • AdT (unregistered) in reply to Jim
    Jim:
    oldtimer:
    These are not GUIDs! GUIDs are hexadecimal and do not contain Q, O, T etc.

    And we must abide by your ID conventions because?

    Oregon lipstick shady memorial function disparity reduce mass.

    I am under no obligation to abide by your English language conventions.

  • spellingnazi (unregistered)

    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)

  • (cs) in reply to bohica61
    bohica61:
    Jonathan:
    (Condensed for your sanity.)

    C'mon! I want to see all 36 levels! I want to have the same awful experience as the OP! The more my head hurts the bigger the WTF!

    But did you bring the amulet back?

  • Jake (unregistered) in reply to spellingnazi

    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.

  • jb (unregistered)

    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)

  • calloatti (unregistered) in reply to Jake
    Jake:
    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.

    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.

  • Roger Wolff (unregistered) in reply to Sakkie
    Sakkie:
    TRWTF is that the "GUIDs" have letters higher in the alphabet than F at the end - methinks those "GUIDs" were handwritten
    No. I don't think so. From the "evidence" (those GUIDs), I suspect that someone coded something like:

    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.

  • (cs)

    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...

  • (cs) in reply to J
    All KillTheChildren does is waste time.
    Too true. You should kill them as babies. That way you don't have to wait three or four years.

    Or if you're in a rush, a roundhouse to the uterus might do nicely.

  • JohnFx (unregistered) in reply to Yazeran
    Yazeran:
    Fra Diavolo:
    What really mystify me is that GUID 1 and 7 are the same...

    Shouldn't it be a Key??

    Yea I noticed that too.. makes them not quite so unique eh? :-)

    Yours Yazeran.

    Plan: To go to Mars one day with a hammer.

    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.

  • buzzenwell (unregistered)

    This appears to be the code that they are using for the U.S voting terminals....

  • tbrown (unregistered) in reply to Dave G.
    Dave G.:
    A function named KillKenny is probably better than a function named RootRachelle.

    But I would love a ForkIrishGirl function!!! Or, very useful, a CloneIrishGirl.

  • Cbuttius (unregistered)

    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.

  • (cs) in reply to tbrown
    tbrown:
    Dave G.:
    A function named KillKenny is probably better than a function named RootRachelle.

    But I would love a ForkIrishGirl function!!! Or, very useful, a CloneIrishGirl.

    Simple: IrishGirl.Clone();

    assuming IrishGirl inherits from Object, anyway... (did I just objectify Irish Girl? The feminists are gonna lynch me...)

  • Mitur Binesderty (unregistered)

    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.

  • (cs)

    yay, another reason not to use 8 spaces for a tab (1 indent)....

  • eMHa (unregistered)

    Line 1 and 7 is equal!?

  • Wolfgang (unregistered)

    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

  • Wizou (unregistered)

    {8B6AA623-F413-4A9C-8703-4D76996E32E} appears twice in the top 10 ??

    guid are not supposed to be unique ?

  • Jonathan (unregistered)

    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:

    For lngIndex = 1 To mcolItems.Count
      Set objLocalVariable = mcolItems.Item(lngIndex)
    
      ' Here is the line of code from the original
      Set objLocalVariable = Nothing 
    Next lngIndex
    

    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:

    Set mcolItems = Nothing
    ...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. :-)

  • Scott (unregistered)

    Actually, you mean 2^126, because of the variant field (section 4.1.1 of RFC 4122).

Leave a comment on “One In 3.4*10^38”

Log In or post as a guest

Replying to comment #:

« Return to Article