• uncool (unregistered)

    looks like someone really liked the game 'red light green light'

  • Robert Carr (unregistered)

    shudders

  • diaphanein (unregistered) in reply to Robert Carr

    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.

  • (cs)

    Yeah, I've always been confused by when to use loops...

  • (cs)

    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.

  • (cs)

    I love how the presentation and data layers have been blended together. Image you are tasked with adding/removing a page.

  • (cs)

    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

  • Tom the Quantum Computing Guy (unregistered)

    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.

  • (cs)

    But .Net has booleans! and they're not even red and green!

    *CRIES*

  • (cs)
    Alex Papadimoulis:
    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.


    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

  • boohiss (unregistered)

    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.

  • (cs) in reply to Tom the Quantum Computing Guy
    Anonymous:
    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.


    Naw man. d00d was totally feeling the Christmas spirit when he coded this lump of shit.
  • (cs)

    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

  • (cs)

    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":

    1. How come Is_Complete_Page1 and IsComplete_Page25 are varchar(15) but IsComplete_Page2 is varchar(10)?
      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).
  • JS (unregistered)

    I use the bit datatype for booleans in SQL Server.

  • (cs)

    I say it was coded by a monkey!!!

     

    Bring back Gorillaz!!

  • (cs) in reply to JS

    Anonymous:
    I use the bit datatype for booleans in SQL Server.

     

    me too! but that makes to much sense?!?!

  • (cs)

    But why isn't it in third-normal form? It's just wrong. [8o|]

    Codd is spinning in his grave.

  • (cs) in reply to LaurieF

    I think I know the guy who wrote that...[+o(]

  • Dave L (unregistered)

    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!

  • JuJuBe (unregistered)

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

  • (cs) in reply to LaurieF
    LaurieF:
    But why isn't it in third-normal form? It's just wrong. [8o|]

    Codd is spinning in his grave.

    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


  • (cs) in reply to Dave L

    Anonymous:
    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!

    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]

  • (cs) in reply to BlackTigerX

    BlackTigerX:
    I think I know the guy who wrote that...[+o(]

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

  • (cs) in reply to JuJuBe

    Are you serious? A boolean is now a tri-value? Wow.

    I think he means the field is only really a boolean if it's declared as NOT NULL.

  • (cs) in reply to boohiss

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

    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.

  • (cs)
    Alex Papadimoulis:

    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.



    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

  • (cs) in reply to Dave L

    Anonymous:
    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!

    Actually, I think they'd just be yellow.

  • enigmatic (unregistered)

    Perhaps I should stick with "Yup"/"Nope"/"Meh"

  • (cs) in reply to Gene Wirchenko
    Gene Wirchenko:
    This statement is a WTF itself.

    Yup.  In addition to your criticisms, all you need is a "not null" constraint to knock the "tri-state logic" down to binary.
  • (cs) in reply to rbriem
    rbriem:

    Anonymous:
    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!

    Actually, I think they'd just be yellow.

    So it would only be a problem for the original Green Lanterns?

    In varest char, in one-bit byte 
    No column shall escape my sight
    Let those who worship first-normal's might
    Beware my power, Green AppForm's light!
  • (cs) in reply to Gene Wirchenko
    Gene Wirchenko:
    Alex Papadimoulis:
    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.


    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



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

  • (cs) in reply to Gene Wirchenko

    Gene Wirchenko:
    Alex Papadimoulis:
    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.


    This statement is a WTF itself ... Some DBMSs do not have boolean.  Some do.

    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.

  • Brian (unregistered)

    The big WTF is that the programmer didn't consider the future problems this would cause if the next programmer was red-green colorblind.

  • Alun Jones (unregistered) in reply to ferrengi

    ferrengi:
    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)?

    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"]

  • (cs) in reply to OneFactor

    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.

     

  • (cs) in reply to WTF Batman

    WTF Batman:
    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.)

    From a logic perspective, this still does not make a Boolean type, merely a constrained domain.

  • (cs) in reply to Alex Papadimoulis
    Alex Papadimoulis:

    From a logic perspective, this still does not make a Boolean type, merely a constrained domain.



    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.

  • Clinton Pierce. (unregistered)

    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.

  • (cs) in reply to Alex Papadimoulis
    Alex Papadimoulis:


    All Relational Databases that I know of support NULL. When the concept of NULL is introduced, you have tri-value logic.



    Sybase ASE does not support nullable BIT datatypes.

    Go ahead, ask me how I know this.
  • OgT (unregistered)

    Anyone ever seen the Red Green Show on PBS?

  • (cs) in reply to Suck My Lisp

    Suck My Lisp:
    Gene Wirchenko:
    This statement is a WTF itself.

    Yup.  In addition to your criticisms, all you need is a "not null" constraint to knock the "tri-state logic" down to binary.

    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.

  • (cs) in reply to OneFactor
    OneFactor:

    Suck My Lisp:
    Gene Wirchenko:
    This statement is a WTF itself.

    Yup.  In addition to your criticisms, all you need is a "not null" constraint to knock the "tri-state logic" down to binary.

    Young grasshopper, observe the stored procedure. ...[snip]... And that, young grasshopper is why you need to place a W in front of the sacred letters of Boolean Algebra: TF.



    Genius! Pure, unadulterated genius!
  • Fregas (unregistered)

    This is because its in VB.NET, instead of C#.

    Let the flame wars begin!!!

  • (cs) in reply to OneFactor

    somewhere in the distance a gong is heard

  • (cs) in reply to OneFactor
    OneFactor:
    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.


    Transcending and not transcending: the new duality.

    Sincerely,

    Gene Wirchenko

  • Shadow Wolf (unregistered) in reply to OneFactor
    OneFactor:
    rbriem:

    Anonymous:
    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!

    Actually, I think they'd just be yellow.

    So it would only be a problem for the original Green Lanterns?

    In varest char, in one-bit byte 
    No column shall escape my sight
    Let those who worship first-normal's might
    Beware my power, Green AppForm's light!
  • (cs)
    Alex Papadimoulis:
    "green"/"red".


    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.
  • (cs) in reply to John Bigboote

    Sybase ASE does not support nullable BIT datatypes. Go ahead, ask me how I know this.

    how do you know this?

  • (cs) in reply to JS
    Anonymous:
    I use the bit datatype for booleans in SQL Server.


    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.

Leave a comment on “The Green, the Whole Green, and Nothing But the Green”

Log In or post as a guest

Replying to comment #:

« Return to Article