- 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
Admin
Back during the dot.com boom I wrote a program for a search system, which added search terms to a list that would then be used by the next pass of an indexer. Each of the load balanced servers produced one of these lists, which were periodically locked by my program, sorted, had the duplicates removed, the results sent to the indexer and the file truncated back to zero before the lock was released. The trouble started when I noticed that the files had a "dic" extension.
Removing a file from service was accomplished by withdraw_dic(). The duplicates were then sorted to the top of the list - this was not the most efficient algorithm, but allowed me to then remove the duplicates with clean_tip_of_dic(). Putting the file back into service, rather than just junking the file once I was done, was accomplished by reinsert_dic().
Admin
Some of them are. At least one of them is a three-piece suit.
Admin
Admin
LOL... KillAllChildren does nothing... and I am utterly amazed that this went unnoticed. That by itself is a WTF. If it did what the programmer intended... then it would create a collection of null references. That would be sooooooo much better!
capcha: aptent (a new microsoft objects that let your applications sleep peacefully under the stars, only $99 USD or $139 in Canada)
Admin
OBKillTheChildren
In the codebase I maintain, there is a generalized TCP transport manager. I'ts pretty simple, with a master thread, that communicates with the rest of the system, and two threads for reading and writing. Now, the funny thing is one of the debug messages:
Parent finish killing children, now comitting suicide.
Admin
That KillTheChildren sub does nothing. It's setting a variable to an item in the collection, then setting it to nothing, leaving the original item untouched. He may as well be counting to ten through a for-loop and then setting the value back to zero again on the very next line.
Admin
(After all, 128 bits would never be enough to enumerate all our employees.)
Admin
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!
Admin
All of these comments about language that appears innapropriate out of context, and no one has yet mentioned the classic OOP one - public and private parts. Certainly a fun conversation to have with a small group in an area with multidisciplinary eavesdroppers.
Admin
Admin
Yep, AFAIK, KillAllChildren does nothing more than waste resources...
The m in mcolItems suggests to me that it is in fact a property of a class (i.e. not global) because in college our VB.NET textbook used a similar naming scheme. IIRC, the 'm' stood for "module scope" and was used for class members.
AFAIK, VB6 and all variants (VBA, VBScript, etc.) don't support "short circuiting" so if you had a logical expression with 20 operations they would all be evaluated, even if the result was determined by the first. So the second snippet might be an example of premature "optimization"... VB.NET added special operators that do short circuit instead of just making the regular operators short circuit (you know, in case you want to waste cycles) so if the programmer wasn't aware of the alternative operators he might have still thought of it as an "optimization". Whether those values should have all been stored in a single variable depends on the application, but I think it's still safe to assume there was a much better way. :P
Admin
The KillTheChildren function really begs for a comment with a quote from A Modest Proposal.
Admin
I give up. My brain has finally completely turned to mush.
Alzheimer's, here I come.
Admin
A long long time ago (the code was on a PDP-11, it was that long ago), I was going through some code written by a coworker and found a routine called "birth()". Intrigued, I took a look, and saw the comment
/* Birth - prevents abortion */
Admin
I am aware of one company that arbitrarily changes one character of their product's GUID with each release, rather than generating a new one. So whereas a new GUID would be guaranteed uniqueness (uniquity?), that group is settling for a small but unknown chance of conflict.
I can understand that when something takes a lot of work, but generating a GUID? I just checked; it's all of four mouse clicks. Why would you accept ANY chance of an undoubtedly hard-to-identify bug to avoid four mouse clicks a month?
Admin
I wrote a letter to my grandma on my TRS-80 Model 100 computer. It allowed six-letter file names so I named the file "grandma". When I went to delete the file, I had to type "kill grandma".
Admin
Yes, you are correct.
All KillTheChildren does is waste time.
Admin
A common GUID generator would not create GUIDs so similar to each other, even with a short time difference.
On the other hand, a Sequential GUID generator creates GUIDs similar to each other on purpose (sorting, indexing...).
The non-hex characters are cute, though :)
Admin
So, it is more common than you think, you think?
Admin
Traditionally, GUIDS tend not to include 'Q' 'T' 'N' etc....
Admin
Except in GUIDs that use a timestamp, there are two fields - one is the timestamp itself, which is based on the number of 100ns periods that have elapsed (yes, 100 nanosecond periods). And just in case you had a fast machine, there's a small counter that resets every 100ns and increments per-GUID so if you manage to generate two in 100ns, they'd still be unique. (Yes, you can temporarily run out of GUIDs if you try to make enough in 100ns to overflow the counter).
Admin
Where's the short version?
If blnContinue and CreateConnection and DeleteData and CreateLocations and SaveServiceProviders and LoadServiceProviders and LoadCategoryNames and LoadFiveServiceProviders and CalculateAllActivations and UpgradesCalcNoExchange and UpgradesCalcExchangeReturns Then ' (25 more levels here) End If
Look at all the space saved!
Admin
Admin
Could have been worse:
Admin
Admin
Admin
the nested if's are likely an offshoot of old VB code.. in VB "and", unlike in almost every other modern language, is not short-circuited. That is, if you do:
If Foo() and Bar() Then ... End If
Where Foo() and Bar() both return booleans, even if Foo() returns false (thus it doesn't matter what Bar() returns, the statement will never evaluate to True), Bar() will also execute.
"Or" works the same way - if you have (Foo() Or Bar()) even if Foo() returns true (again, it doesn't matter what Bar() returns, the statement evaluates to true) it will run Bar() anyways.
They do have a way around this: "AndAlso" and "OrElse". OrElse you can just use a crazy set of nested ifs, AndAlso get yourself on thedailywtf..
Admin
All this talk about functions like KillTheChildren() and disinfect_dic() prompted me to dig up my source code for the first game I tried to make 10 years ago, called "Splatter Mario". It's VB6, with DirectX, and naturally full of WTFs with function names including:
Made me laugh, anyway. I'll leave you with this horrible yet poetic function used in many places throughout the source code:
Admin
Admin
Our product managers had to come up with a new term for "Bill Of Materials" when talking about what will go into our shrink wrapped boxes. For some reason talking about a BOM in public attracts a lot of attention.
Admin
Admin
yup. but why did you forget to mention that a class' friends have access to it's private bits?
Admin
Admin
You do realize that if you use Guidgen, you aren't guaranteed to generate a globally unique ID? Not to mention someone could maliciously use your GUID as their own.
Admin
if guidInUse(8B6AA623-F413-4A93-8703-4D76996E632E) then if guidInUse(8B6AA623-F413-4A93-8703-4D76996E632Q) then if guidInUse(8B6AA623-F413-4A93-8703-4D76996E631E) then if guidInUse(8B6AA623-F413-4A93-8703-4D76996E632O) then if guidInUse(8B6AA623-F413-4A93-8703-4D76996E632T) then //What was I suppose to do here? end if end if end if end if end if
Admin
if Bored then if AtComputer then if InternetWorking then if TheDailyWTF then if NewArticle then if AnythingToSay then '...25 more levels here... PostComment("captcha", "feugiat") end if end if end if end if end if end if
Admin
The WTF here is a lack of knowlege of SQL Server by the operators of this site.
NEWSEQUENTIALID() is built in to sqlserver and causes new sequential GUIDs to be created. This is used when the privacy of the GUID is not an issue and improves perforamnce when GUID is being used in an index.
http://msdn.microsoft.com/en-us/library/ms189786.aspx
Admin
Admin
Admin
And this, ladies and gents, is why GOTO's are so important to teach at college.
If not blnContinue GOTO 1 If not CreateConnection GOTO 1 If not DeleteData GOTO 1 If not CreateLocations GOTO 1 If not SaveServiceProviders GOTO 1 If not LoadServiceProviders GOTO 1 If not LoadCategoryNames GOTO 1 If not LoadFiveServiceProviders GOTO 1 If not CalculateAllActivations GOTO 1 If not UpgradesCalcNoExchange GOTO 1 If not UpgradesCalcExchangeReturns GOTO 1 call comment("The importance of GOTO's") 1:
Todays kids don't even know about all the powerful programming techniques anymore. How sad.
Admin
Because GUID is a type defined in RFC 4122 (actually UUID, which GUID is an implementation of)?
It's like asking why an integer can't contain ".5" or a decimal can't contain "j".
"Because then it's not an integer, a decimal, or a GUID."
Nobody says you have to use GUIDs - by all means, you can make some looks-like-a-GUID-at-a-glance-but-isn't format.
But you shouldn't call it a GUID, precisely because it isn't one and if you (or, worse, some other poor bastard) later try to treat it as one, it'll bite you. Hard.
(Think of the fun a later programmer will have trying to cast those non-GUID values to a GUID type (or use them in a constructor).)
Admin
One of my favorite function names I ever got to use (at least in a way that actually described its operation) was ReapZombieChildren.
Admin
Aaron, the WTF isn't the exact contents of the GUIDs, those were probably manually changed to protect privacy, and probably by someone who didn't really understand what a GUID was. In both the name of the post and the comments in the post, the claimed problem was the sequential nature of the GUIDs. I'm saying that creation of sequential GUIDs are is a feature built in to SQL Server and used for valid reasons.
Admin
author must die
Admin
mcolItems is not defined in the code snippet. From the code we can see that m_col_Items is a Collection of Items. Each object in that collection is set to Nothing. So we start with a collection like this:
and we finish with a collection like this
or like this
(I make no assumptions about the what a collection is or how it works)
There is an extra line at the bottom of the routine:
This is a WTF. It indicates that the original author is a C code weaner (I must always set my objects to nothing) or an ASP code weaner (I must always set my objects to nothing), or has simply learned his coding from documentation code snippets (I must always set my objects to nothing).
Or, to be generous, perhaps it was just an A/R coding standard which insisted (You must always set your objects to nothing).
Maybe a policy like that is sensible if there are a lot of coders out there who can't read even a simple 3 line code snippet without an egregious misunderstanding.
Admin
"The fault, dear Brutus, is not in our stars," [Julius Caesar(I, ii, 139)]
"Our remedies oft in ourselves do lie, Which we ascribe to Heaven." [All's Well That Ends Well (I, i, 231-232)]
Admin
Looks like someone f*cked UUID three times over. Give it some Q's and some J's, why not?
Admin
Now that's some bad-ass VBScript
Admin
As long as the first GUID they started the sequence with was properly generated, simply incrementing from there doesn't strike me as particularly increasing the chance of a conflict.
Addendum (2008-11-01 00:42): (Well, okay, I suppose it does reduce the randomness by a factor of 16 or 256, since you're essentially removing the randomness of the last one or two digits, but that doesn't seem like a big deal when you're dealing with a range of 340282366920938463463374607431768211456.)