- 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
I'm currently writing an application that must display a list of items (like a catalogue). The items can live online to be downloaded and displayed, or retrieved from the client PC. The user can choose to view either online items, offline items or both. Perhaps this code is for something similar.
Admin
The only possible reason i could think of for this are
The user has subscribed for some content which has both an online and offline component and this checks whether to provide them with both, that would also explain why it's in a stored proc.
If this is the case it's still a bit wftey but kind of understandable
Admin
The 'users' of this application are actually spin-1/2 particles, and thus need the possibility of being in a linear superposition of two states. Come on guys, basic quantum mechanics.
Admin
...at which point the entangled system goes into the opposite state. Bugger!
Admin
The real WTF is T-SQL's stored procedure syntax. I mean, who needs semicolons when the DB can just guess the start and end of your queries!
Admin
I don't know why there is an argument over how NULL/UNKNOWN are suppossed to be handled in logic. There happen to be two very good systems binary and trinary (digraph, and trigraph). Boolean fields have two possible values and a third that may or may not be imposed by the database, all you have to do is tick or not the "required" option. If its required it can't store null (binary logic) otherwise welcome to the joys of any operation on null returns null.
you get a null. and that makes the statement (just before evaluation completes) auto mutate into a false.
Moral of the story only perform mission critical actions in the true part of an if (especial when there are nulls about).
I just saw the tortoise pass by...
they failed to mention that the cat could have a third state, bloody furious.
CAPTCHA: cognac (Yes please)
Admin
It's not a guess. The end (and thus the start) of each statement is precisely defined. The only reason to require semi-colons would be that you like typing.
Admin
This is T-SQL, so those values are ('Y', 'N', NULL).
Admin
but online and offline are undefined in some cases!!
Captha: smile ;)
Admin
The guy is just a retart. face it.
Admin
To use a clichéd pharse around here, "The real WTF is..." is the discussion in defence of this outrageous wackyness (or grudging grossly understated acknowledgments along the lines of "well it is a bit wacky...").
I see no compelling argument that this any but a complete "WTF?!".
Sadly, I see madness like this fairly frequently (I can think of a similar very specific case of DB failover handling I've come across not too long ago) and find it depressing that people stick up for this sort of nonsense, let alone try and justify it.
I'm entirely understanding of the sort of icky code and dubious kludges we all do from time to time, but the ingenious stupidity of the person who thought this up terrifies me.
The poster who brought up the 'Gloves!' article was spot on.
I might print this off and show this to canidates during interviews to see if I can get a feel for their revulsion to this sort of thing.
Admin
i think you even cannot compare to null - you have to use the IS statement
(WHERE col IS NULL // WHERE NOT col IS NULL instead of WHERE col = NULL // WHERE col != NULL)
Captcha: dreadlocks - funny... i have problems with deadlocks in here...
who messed the r into my captha!?
Admin
the real WTF is his failure to handle the "isVeryOnline" or "isVeryOffline" status.
Admin
This is a clear example of Childhood Logic. Children do crazy-dumb things everyday that make perfect sense to them, and yet they don't know why they did it in the first place!
Admin
Also, I want to see the rest of the code, especially the part that sets OnlineOffline to 'Both'. Only then can I determine if this code is truly WTF-Worthy or if it indeed makes sense from a larger perspective....or 'Both'!
Admin
Ahh, but that's not identical to the assumed intent. If @OnlineOffline = 'Both', that code would return all rows, where the original would only return those where the value is 'Y' or 'N', and not rows where it's NULL or 'WTFCentaurs'. Gotta love NULL.
Admin
You CAN have a system both online and offline. For example Yahoo Messenger. You have a setting there that allows you to apear offline to everyone else, while you are actually online. Then you can stare for ages at the buddy list wondering why isn't anyone saying something to you. The varchar was used for extensibility. Maybe a module that would be developed latter will require a stronger Yes, like someone sugested before. However, I wonder what would happen if you finish with a value for that thing like: "YYYYYYNYYYY". This sounds like that computer nightmare.
Captcha is "waffles" and you can see from my post I'm not hungry. Or sleepy.
Admin
Admin
Actually I know one place where this "both offline and online" stuff would've worked. Some years ago I worked for a company that tried to do messaging crap with huge money pouring in after they made some slideshows about projections and stuff that never realized. There the person could get their messages delivered online (directly to their messaging app), offline (to the offline store, e.g. IMAP mailbox) or both. So in that case it would be reasonable to see a state "both" for offline and online.
You're just too narrow minded to think that it's always a question of someone's online status... :)
Admin
Precisely what I thought. I mean, what the... even if he wanted to do something dumbtarded, there's a reason for SET (Which I still feel would be inappropriate), however, if this was used to test, say, if a user has access to a feature both in 'online' and 'offline' mode..
It's still fucking wrong, though.