- 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
looks like someone really liked the game 'red light green light'
Admin
shudders
Admin
Usually, I think people jump the gun when claiming code is generated, but for once I actually do think this was generated. Rather moronically of course.
Alternatively, the original other was just exercising premature optimization (think loop unrolling), which is, of course, the mother of all f***-ups.
Admin
Yeah, I've always been confused by when to use loops...
Admin
Uhm ... I think BOOL or BOOLEAN is a standard SQL type, and even if not, quite a few RDBMSs have it: Postgres, MySQL (as an alias for TINYINT), I'm sure there are more.
Admin
I love how the presentation and data layers have been blended together. Image you are tasked with adding/removing a page.
Admin
Boolean values are over used anyways. The flexibility of a character or string type is much preferred.
example: Why use just True or False when one could use, 1, 0, T, F, Y, N, null, FileNotFound, and Purple all as valid values!
/sarcasim
Admin
Is there any chance the green/red might relate to the checked/unchecked image in the ImageUrl? I know it's common among developers to display a green checkmark to indicate a valid result whereas a red X is used to indicate an invalid result. Not that this excuses the rest of the code's structure but it may somewhat explain the developer's thinking in regards to the red/green boolean logic.
Admin
But .Net has booleans! and they're not even red and green!
*CRIES*
Admin
This statement is a WTF itself. If you require tristate logic, then do not use binary logic. This is much the same as selecting a fixed decimal type when representing currency instead of using integers. Pick the appropriate type.
Some DBMSs do not have boolean. Some do.
Sincerely,
Gene Wirchenko
Admin
I don't think SQL Server has boolean, but it does have a 'bit' data type, which can be 1/0 (of course).
ASP (at least) interprets the bits as "True" or "False" in an ADO recordset.
Admin
Naw man. d00d was totally feeling the Christmas spirit when he coded this lump of shit.
Admin
Great! Now I have this song running through my head. Someone please feed me to the giant man-eating Iranian cockroaches, so I can find some comfort!
http://www.pythonland.com/song25.php
Admin
Ummm, what the hell is this?
Is the content for each of the webpages being stored on the database?
Each page has it's own Content, Title and IsComplete column? If they are all completed, the form can be submitted?
Assuming I got all that right, a few questions for the "developer":
At least if you are going to royally screw up, be consistent!
2) Also, since these Is_Complete columns only have values of "green" or "red" (or maybe "null" since they have to put something in there because the column is defined as NOT NULL, which is also stupid. The content and title can be NULL but Is_Complete must have a value! WTF?!). Anyway, I digress, why does the column need to be varchar(15), what's wrong with varchar(5)?
Not that he would care anyway because it could easily have been stored as char(1), 'G' or 'R' or better yet 'Y' or 'N' (on second thought, that would be too easy).
Admin
I use the bit datatype for booleans in SQL Server.
Admin
I say it was coded by a monkey!!!
Bring back Gorillaz!!
Admin
me too! but that makes to much sense?!?!
Admin
But why isn't it in third-normal form? It's just wrong. [8o|]
Codd is spinning in his grave.
Admin
I think I know the guy who wrote that...[+o(]
Admin
If they replace true and false with #00ff00 and #ff0000 then I'll be impressed.
Of course when they come across #ffff00 then they're fucked!
Admin
"Relational databases don't have Boolean data types for good reason: the inherent nature of tri-value logic (i.e., true, false, and unknown/null) makes it a logical impossibility."
Seriously, what?
Are you serious? A boolean is now a tri-value? Wow.
http://www.postgresql.org/docs/7.4/interactive/datatype-boolean.html
http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html
Anyway, yes, using Green/Red is kinda dumb, but no dumber than saying boolean is a 'tri-value'.
Admin
I doubt it. If he were, given the atrocities committed with DBMSs, someone would have attached a generator to him, and we would have heard of this near-infinite source of electrical power.
Sincerely,
Gene Wirchenko
Admin
Gives a whole new meaning to the word phrase #ffff00 barred.
As for the bit datatype in SQL Server, my favorite part is when I open up the table in design mode and find out that the column allows nulls.
Though why we are fussing about the red-green thing when the table is not even in first normal form boggles the mind. Table which are not in first normal form make baby Jesus cry. The worst that the red-green would do is make Santa Claus turn over in his grave [:P]
Admin
Assuming you're not just joking here, do you know what the application was for? Was it a 25 page web site stored in the DB, or...?
Admin
I think he means the field is only really a boolean if it's declared as NOT NULL.
Admin
Bit can be 1, 0 or null. This may sound picky, but I have seen T-SQL such as this:
IF @bitParam = 0...
Which doesn't get invoked if @bitParam is null.
Admin
I'm going to assume the users who have claimed that this statement is in itself a WTF are either (1) familiar with the WTFs this is a sarcastic reference to, and are themselves being sarcastic or (2) new to TDWTF
Admin
Actually, I think they'd just be yellow.
Admin
Perhaps I should stick with "Yup"/"Nope"/"Meh"
Admin
Yup. In addition to your criticisms, all you need is a "not null" constraint to knock the "tri-state logic" down to binary.
Admin
So it would only be a problem for the original Green Lanterns?
Admin
And, of course, this "tri-state" nature of said "boolean" data type is easily obviated by simply adding "not null" to the column definition.
Booleans are easy to create. Add a check constraint to make sure the value is 0 or 1 (or T/F, or R/G, or...) and a "not null". How to do so on each RDBMS varies, but it's by no means impossible, or even difficult. (mysql users can use an enum column, instead of check, I believe.)
Admin
All Relational Databases that I know of support NULL. When the concept of NULL is introduced, you have tri-value logic. The concept of tri-value is a bit foreign since the overwhelming majority of languages are Boolean-logic based.
With Boolean logic, "x || !x" (where x is a boolean expression, such as "y == z") is a tautology. In tri-value logic, it is TRUE or NULL. Even the expresion "m == m" is could be TRUE or NULL in tri-value.
This is why tri-value languages will have an IsUnknown or IsNull test, which is the only thing that can be used to compare such values.
Hopefully you now understand why it is therefore impossible to have a Boolean datatype (two values) within a tri-value system.
Admin
The big WTF is that the programmer didn't consider the future problems this would cause if the next programmer was red-green colorblind.
Admin
The answer is obvious - if you've been around the computing field as long as I have, you'll have come across the issue of trying to translate an app to a foreign language. The 15 character size is designed to take into account the possibility that the words for "red" and "green" in some foreign language might be very long indeed.
Or maybe it's to provide for future requirements - someone may want to include "chartreuse", or "azure", maybe even "Post Office Red" (15) or "British Racing Green" (oh, poopies).
[Oh, that's subtle - the failed captcha is "register"]
Admin
Heh. I've seen the True/False/Null nature of a relational database mess people up sometimes, when they forgot to put a NOT NULL on the declaration or didn't know that they could.
Although the more usual workaround to this essentially turns that trinary into a binary by simply treating a intended boolean field only with "IS NULL" or "IS NOT NULL" in the statements regarding it. Then any value in the column becomes "true" and null in the column becomes "false". Or vice-versa.
Admin
From a logic perspective, this still does not make a Boolean type, merely a constrained domain.
Admin
That's true, but from the application perspective, that's generally good enough. Most languages interpret 0 as false and 1 as true, so boolean-context comparisons on the ints work as expected.
You're right in that this is a kludge, but it's a good kludge in that it at least only allows logically true/false values and nothing else (red and green, for instance). Certainly helps from a data integrity perspective.
I remember a WTF a while ago about a TPS report where it was "reportable" with like 10 different varieties of "yes" or "no". This kludge would, at least, prevent insane cases like that.
Admin
The programmer was obviously Canadian, and as we all know:
If the women don't find you handsome they should at least find you handy.
Admin
Sybase ASE does not support nullable BIT datatypes.
Go ahead, ask me how I know this.
Admin
Anyone ever seen the Red Green Show on PBS?
Admin
Young grasshopper, observe the stored procedure. Meditate on the beauty of its parameter declaration. See how the tiny bit datatype wishes to be free of the dualism imposed by two-valued western logic. For if the student knows NOTHING can be other than one or zero, the enlightened will learn know that nothing CAN be other than one or zero. Even as the brutish developer tries to coerce the parameter into but two values by providing a default of zero, the parameter yields like the slender reed to the howling storm and allows itself to be invoked with an explicit null.
Consider also the left-outer join as it frolicks in your view. Unlike the inner join which only gives after it has received, the left-outer join has transcended selfish greed and the demands for O(n) performance. It can cheerfully give of itself as an orphan who has nothing even without the material riches provided by parents. And in doing so, it too will transcend the duality which the not-null constraint imposes.
To understand the database you must unlearn the dualism you have learned in your computer science. And that, young grasshopper is why you need to place a W in front of the sacred letters of Boolean Algebra: TF.
Admin
Genius! Pure, unadulterated genius!
Admin
This is because its in VB.NET, instead of C#.
Let the flame wars begin!!!
Admin
somewhere in the distance a gong is heard
Admin
Transcending and not transcending: the new duality.
Sincerely,
Gene Wirchenko
Admin
Admin
strings are more expressive than puny, weak bits. this is what happens when you demote a comptroller. never demote a comptroller. revenge assumes many chloroforms.
Admin
how do you know this?
Admin
Meh. I use the smallest flavor of int, whatever it happens to be. Sounds a little wierd, but if you need to be able to represent null, you need more than 1 and 0. I prefer null = -1 myself, because -1 fits into a lot of languages built in error checking procedures.