Who needs boolean columns? Or an int bitmask value?



  • Recently seen in the DB of one of my products, slightly anonymized:

    Columns foo int, bar int, bits nvarchar

    Sample value: foo=1, bar=1, bits='1|1|1|1|1|1|1|1|1|1|1|'

    *cry*



  • Could be worse: bits='1|0|1|0|FileNotFound|1|0|...'

     



  •  Who needs more than one column anyway? Just cram it all in there, username, password, etc:

    pbean|94e1b5580c5085109a54583dfbb0d4970189a0f5|1973

    Wait, we can even make this dynamic!

    username|pbean|password|94e1b5580c5085109a54583dfbb0d4970189a0f5|year|1973

    Just make sure the DBMS you're using supports very long column sizes.



  • @pbean said:

     Who needs more than one column anyway? Just cram it all in there, username, password, etc:

    pbean|94e1b5580c5085109a54583dfbb0d4970189a0f5|1973

    Wait, we can even make this dynamic!

    username|pbean|password|94e1b5580c5085109a54583dfbb0d4970189a0f5|year|1973

    Just make sure the DBMS you're using supports very long column sizes.


    I think you mean
    username|pbean|password|06009aecae03bf27dc9322ec4f02294f|year|1973



  • @Adriano said:

    I think you mean username|pbean|password|06009aecae03bf27dc9322ec4f02294f|year|1973
     

    At first I didn't get it, but then I saw your brillance. 



  •  Ahem... near brillance. The password is clearly supposed to be SHA-1'd:

     username|pbean|password|5282bd429d6f52316bf9155d15d853306e63cb08|year|1973



  • @superjer said:

     Ahem... near brillance. The password is clearly supposed to be SHA-1'd:

     username|pbean|password|5282bd429d6f52316bf9155d15d853306e63cb08|year|1973

     

    Wrong.  The password must absolutely be ROT13'd.

     username|pbean|password|oevyynag|year|1973

    Although the entry is still pipe-delimited.  This is 2008, people!

    <account>

    <username>pbean</username>

    <password>oevyynag</password>

    <year>1973</year>

    </account>



  • Storing everything in a single table cell, with such separators among the stored values... ASP.NET's profile provider works kinda like that, you know.



  • @snoofle said:

    Could be worse: bits='1|0|1|0|FileNotFound|1|0|...'

     

    There's worse in one of the products we had at my last job:

    #define BINARY_ZERO ((unsigned char) 0)
    #define BINARY_ONE ((unsigned long double) 1)
    #define BINARY_ONE_THAT_WORKS ((unsigned char) 1)

    Later in the code you see crap like:

    x=(BINARY_ZERO << 1) + (BINARY_ZERO << 1) + ... + (BINARY_ONE_THAT_WORKS << 1) + (BINARY_ONE_THAT_WORKS << 0);
    To create the number 7 in "bit mask format", according to the comment.

    There are 100 kinds of people in the world: Those that understand binary, those that don't, those that almost grasp it, and those I want to hit with a hammer for trying.



  • @Wolftaur said:

    [

    There's worse in one of the products we had at my last job:
    #define BINARY_ZERO ((unsigned char) 0)
    #define BINARY_ONE ((unsigned long double) 1)
    #define BINARY_ONE_THAT_WORKS ((unsigned char) 1)

    I'm not sure which is better or worse, but I've also seen (IIRC):

    #define COMMA , 
    Yeah, not even comma in a string, just comma. I suppose I should be impressed that it wasn't #define'd as THE_THING_IN_C_THAT_SEPARATES_ARRAY_ELEMENTS_IN_AN_INITIALIZER.


  • @AssimilatedByBorg said:

    ITHE_THING_THAT_STARTS_A_COMMENT_LINE_IN_VISUAL_BASICm not sure which is better or worseTHE_THING_IN_C_THAT_SEPARATES_ARRAY_ELEMENTS_IN_AN_INITIALIZER but ITHE_THING_THAT_STARTS_A_COMMENT_LINE_IN_VISUAL_BASICve also seen THE_THING_THAT_STARTS_A_TYPE_CAST_IN_C_C_PLUS_PLUS_C_POUND_JAVA_AND_PROBABLY_A_LOT_MOREIIRCTHE_THING_THAT_ENDS_A_TYPE_CAST_IN_C_C_PLUS_PLUS_C_POUND_JAVA_AND_PROBABLY_A_LOT_MORE:

    THE_THING_THAT_STARTS_A_COMPILER_COMMAND_IN_Cdefine COMMA THE_THING_IN_C_THAT_SEPARATES_ARRAY_ELEMENTS_IN_AN_INITIALIZER 
    YeahTHE_THING_IN_C_THAT_SEPARATES_ARRAY_ELEMENTS_IN_AN_INITIALIZER not even comma in a stringTHE_THING_IN_C_THAT_SEPARATES_ARRAY_ELEMENTS_IN_AN_INITIALIZER just commaTHE_THING_THAT_SEPERATES_THE_NUMBER_HIGHER_OR_EQUAL_TO_ONE_AND_THE_NUMBER_LOWER_THAN_ONE_IN_DECIMALS I suppose I should be impressed that it wasnTHE_THING_THAT_STARTS_A_COMMENT_LINE_IN_VISUAL_BASICt THE_THING_THAT_STARTS_A_COMPILER_COMMAND_IN_CdefineTHE_THING_THAT_STARTS_A_COMMENT_LINE_IN_VISUAL_BASICd as THE_THING_IN_C_THAT_SEPARATES_ARRAY_ELEMENTS_IN_AN_INITIALIZER.
     


  • @AssimilatedByBorg said:

    @Wolftaur said:

    [

    There's worse in one of the products we had at my last job:

    #define BINARY_ZERO ((unsigned char) 0)
    #define BINARY_ONE ((unsigned long double) 1)
    #define BINARY_ONE_THAT_WORKS ((unsigned char) 1)

    I'm not sure which is better or worse, but I've also seen (IIRC):

    #define COMMA , 
    Yeah, not even comma in a string, just comma. I suppose I should be impressed that it wasn't #define'd as THE_THING_IN_C_THAT_SEPARATES_ARRAY_ELEMENTS_IN_AN_INITIALIZER.

    We had a guy do something similar at a place I worked for a couple months. He was mad that some people called ! bang, some called it not. He insisted it be called by its correct name, leading to POINT being defined to !. He also defined INKBLOT to be *, he defined SLASHESS to be $...

    I've never heard anyone else call those symbols by his names for them, either.

    If you're going to abuse the preprocessor, at least do it in fun and useful ways.

    #define ABS(x) (x<0? -x : x)

    On the subject of #define STUPID, we had another guy who wanted to use MAXINT to denote the largest number allowed in a data entry form. It turns out to be in use. Oh no! He edits the relevant file in /usr/include/ and removes the system's definition...



  • Maybe he thought #undef wasn't safe enough?
    Boy, changing system header files just got to take the cake.



  • @Ilya Ehrenburg said:

    Maybe he thought #undef wasn't safe enough?
    Boy, changing system header files just got to take the cake.

    He didn't know about #undef, and when we told him about it, he insisted that if he didn't know about it, it must be a nonstandard extension, and he refused to use it as it would be non-portable. Attempts to point out that requiring a system header be neutered of a rather important constant was not even remotely portable got the response, "That's just because you don't know what portable means." We gave up and let him try to explain to upper management that it wasn't his fault his code compiled but most other stuff no longer did...



  •  Thanks. That is hilarious and depressing at the same time, no, it's far beyond that, words fail me.

     

    Any chance of seeing some code by this guy on the front page?



  • @Ilya Ehrenburg said:

     Thanks. That is hilarious and depressing at the same time, no, it's far beyond that, words fail me.

     

    Any chance of seeing some code by this guy on the front page?

    I'm more likely to submit some stuff done by even dumber programmers. Yes, that's right. I've known dumber. Actually, I've known far dumber. This guy wrote mostly functional code most of the time. Only occasionally did he do something truly bizarre or stupid... but there were others I've known who were much more consistent in inducing migraines and laughter simultaneously.



  •  I hope and fear at the same time.



  • @MiffTheFox said:

    This is 2008, people!

    <account>

    <username>pbean</username>

    <password>oevyynag</password>

    <year>1973</year>

    </account>

    Not flexible enough:

    <account>
    <username encoding="ascii">pbean</account>
    <password encoding="ascii" encryption="rot13">oevyynag</password>
    <year calendar="gregorian" base="10">1973</year>
    </account>
    


  • @Carnildo said:

    <account>
    <username encoding="ascii">pbean</account>
    <password encoding="ascii" encryption="rot13">oevyynag</password>
    <year calendar="gregorian" base="10">1973</year>
    </account>

    Pfft, still not flexible enough. You forgot the secret-type="none" attribute. And you forgot the <privileges> from the account. That alone should be at least 20 more lines of XML.



  • @Wolftaur said:

    Pfft, still not flexible enough. You forgot the secret-type="none" attribute. And you forgot the <privileges> from the account. That alone should be at least 20 more lines of XML.
    Pfft, still not flexible enough. You forgot about extensibility issues! And have I got the solution for you! XML-in-XML!

    <element name="account">
    <element name="username">
    <attribute name="encoding" value="ascii" />
    <cdata>pbean</cdata>
    </element>
    <element name="password">
    <attribute name="encoding" value="ascii" />
    <attribute name="encryption" value="rot13" />
    <cdata>oevyynag</cdata>
    </element>
    <element name="year">
    <attribute name="calendar" value="gregorian" />
    <attribute name="base" value="10" />
    <cdata>1973</cdata>
    </element>
    </element>


  • I inherited a database table with a field called 'PMKEY'.

    In each of the 300 rows of so data, the PMKEY field looks like this:

      <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>IPMS</title>

    <font color="#000000" face="Arial"></font>
    IPMS
    <font style="font-size: 10pt;" color="#000000" face="Arial">PMKEY</font>
    <font style="font-size: 10pt;" color="#000000" face="Arial">|NAME:LCLA03_2|PMACT:REAL|PM2:A4|DIV:A|FCN:LC|FCN:LCL|FCN:ESF|DIVFCN:ALC|DIVFCN:ALCL|DIVFCN:AESF|DIVREDFCN:A1LC|DIVREDFCN:A1LCL|DIVREDFCN:A1ESF|LVL:2|RED:1|REDTOT:1|REDNOFM:11|</font>
    <font style="font-size: 10pt;" color="#000000" face="Arial">|NAME:LCLA03_3|PMACT:REAL|PM2:A5|DIV:A|FCN:LC|FCN:LCL|FCN:RT|DIVFCN:ALC|DIVFCN:ALCL|DIVFCN:ART|DIVREDFCN:A2LC|DIVREDFCN:A2LCL|DIVREDFCN:A2RT|LVL:2|RED:2|REDTOT:2|REDNOFM:22|</font>
    <font style="font-size: 10pt;" color="#000000" face="Arial">|NAME:LCLA03_4|PMACT:REAL|PM2:A6|DIV:A|FCN:LC|FCN:LCL|FCN:COM|DIVFCN:ALC|DIVFCN:ALCL|DIVFCN:ACOM|DIVREDFCN:A1LC|DIVREDFCN:A1LCL|DIVREDFCN:A1COM|LVL:2|RED:1|REDTOT:1|REDNOFM:11|</font>
    <font style="font-size: 10pt;" color="#000000" face="Arial">|NAME:LCLA04_1|PMACT:REAL|PM2:A7|DIV:A|FCN:LC|FCN:LCL|FCN:ESF|DIVFCN:ALC|DIVFCN:ALCL|DIVFCN:AESF|DIVREDFCN:A1LC|DIVREDFCN:A1LCL|DIVREDFCN:A1ESF|LVL:2|RED:1|REDTOT:1|REDNOFM:11|</font>
    <font style="font-size: 10pt;" color="#000000" face="Arial">|NAME:LCLA04_2|PMACT:REAL|PM2:A8|DIV:A|FCN:LC|FCN:LCL|FCN:RT|DIVFCN:ALC|DIVFCN:ALCL|DIVFCN:ART|DIVREDFCN:A2LC|DIVREDFCN:A2LCL|DIVREDFCN:A2RT|LVL:2|RED:2|REDTOT:2|REDNOFM:22|</font>
    <font style="font-size: 10pt;" color="#000000" face="Arial">|NAME:LCLA04_3|PMACT:REAL|PM2:A9|DIV:A|FCN:LC|FCN:LCL|FCN:COM|DIVFCN:ALC|DIVFCN:ALCL|DIVFCN:ACOM|DIVREDFCN:A1LC|DIVREDFCN:A1LCL|DIVREDFCN:A1COM|LVL:2|RED:1|REDTOT:1|REDNOFM:11|</font>
    <font style="font-size: 10pt;" color="#000000" face="Arial">|NAME:LCLA04_4|PMACT:REAL|PM2:AA|DIV:A|FCN:LC|FCN:LCL|FCN:RT|DIVFCN:ALC|DIVFCN:ALCL|DIVFCN:ART|DIVREDFCN:A1LC|DIVREDFCN:A1LCL|DIVREDFCN:A1RT|LVL:2|RED:1|REDTOT:2|REDNOFM:12|</font>
    <font style="font-size: 10pt;" color="#000000" face="Arial">|NAME:LCLB03_1|PMACT:REAL|PM2:B3|DIV:B|FCN:LC|FCN:LCL|FCN:RT|DIVFCN:BLC|DIVFCN:BLCL|DIVFCN:BRT|DIVREDFCN:B1LC|DIVREDFCN:B1LCL|DIVREDFCN:B1RT|LVL:2|RED:1|REDTOT:2|REDNOFM:12|</font>
    <font style="font-size: 10pt;" color="#000000" face="Arial">|NAME:LCLB03_2|PMACT:REAL|PM2:B4|DIV:B|FCN:LC|FCN:LCL|FCN:ESF|DIVFCN:BLC|DIVFCN:BLCL|DIVFCN:BESF|DIVREDFCN:B1LC|DIVREDFCN:B1LCL|DIVREDFCN:B1ESF|LVL:2|RED:1|REDTOT:1|REDNOFM:11|</font>
    <font style="font-size: 10pt;" color="#000000" face="Arial">|NAME:LCLB03_3|PMACT:REAL|PM2:B5|DIV:B|FCN:LC|FCN:LCL|FCN:RT|DIVFCN:BLC|DIVFCN:BLCL|DIVFCN:BRT|DIVREDFCN:B2LC|DIVREDFCN:B2LCL|DIVREDFCN:B2RT|LVL:2|RED:2|REDTOT:2|REDNOFM:22|</font>
    <font style="font-size: 10pt;" color="#000000" face="Arial">|NAME:LCLB03_4|PMACT:REAL|PM2:B6|DIV:B|FCN:LC|FCN:LCL|FCN:COM|DIVFCN:BLC|DIVFCN:BLCL|DIVFCN:BCOM|DIVREDFCN:B1LC|DIVREDFCN:B1LCL|DIVREDFCN:B1COM|LVL:2|RED:1|REDTOT:1|REDNOFM:11|</font>
    <font style="font-size: 10pt;" color="#000000" face="Arial">|NAME:LCLB04_1|PMACT:REAL|PM2:B7|DIV:B|FCN:LC|FCN:LCL|FCN:ESF|DIVFCN:BLC|DIVFCN:BLCL|DIVFCN:BESF|DIVREDFCN:B1LC|DIVREDFCN:B1LCL|DIVREDFCN:B1ESF|LVL:2|RED:1|REDTOT:1|REDNOFM:11|</font>
    <font style="font-size: 10pt;" color="#000000" face="Arial">|NAME:LCLB04_2|PMACT:REAL|PM2:B8|DIV:B|FCN:LC|FCN:LCL|FCN:RT|DIVFCN:BLC|DIVFCN:BLCL|DIVFCN:BRT|DIVREDFCN:B2LC|DIVREDFCN:B2LCL|DIVREDFCN:B2RT|LVL:2|RED:2|REDTOT:2|REDNOFM:22|</font>
    <font style="font-size: 10pt;" color="#000000" face="Arial">|NAME:LCLB04_3|PMACT:REAL|PM2:B9|DIV:B|FCN:LC|FCN:LCL|FCN:COM|DIVFCN:BLC|DIVFCN:BLCL|DIVFCN:BCOM|DIVREDFCN:B1LC|DIVREDFCN:B1LCL|DIVREDFCN:B1COM|LVL:2|RED:1|REDTOT:1|REDNOFM:11|</font>
    <font style="font-size: 10pt;" color="#000000" face="Arial">|NAME:LCLB04_4|PMACT:REAL|PM2:BA|DIV:B|FCN:LC|FCN:LCL|FCN:RT|DIVFCN:BLC|DIVFCN:BLCL|DIVFCN:BRT|DIVREDFCN:B1LC|DIVREDFCN:B1LCL|DIVREDFCN:B1RT|LVL:2|RED:1|REDTOT:2|REDNOFM:12|</font>
    <font style="font-size: 10pt;" color="#000000" face="Arial">|NAME:LCLC03_1|PMACT:REAL|PM2:C3|DIV:C|FCN:LC|FCN:LCL|FCN:RT|DIVFCN:CLC|DIVFCN:CLCL|DIVFCN:CRT|DIVREDFCN:C1LC|DIVREDFCN:C1LCL|DIVREDFCN:C1RT|LVL:2|RED:1|REDTOT:2|REDNOFM:12|</font>
    <font style="font-size: 10pt;" color="#000000" face="Arial">|NAME:LCLC03_2|PMACT:REAL|PM2:C4|DIV:C|FCN:LC|FCN:LCL|FCN:ESF|DIVFCN:CLC|DIVFCN:CLCL|DIVFCN:CESF|DIVREDFCN:C1LC|DIVREDFCN:C1LCL|DIVREDFCN:C1ESF|LVL:2|RED:1|REDTOT:1|REDNOFM:11|</font>
    <font style="font-size: 10pt;" color="#000000" face="Arial">|NAME:LCLC03_3|PMACT:REAL|PM2:C5|DIV:C|FCN:LC|FCN:LCL|FCN:RT|DIVFCN:CLC|DIVFCN:CLCL|DIVFCN:CRT|DIVREDFCN:C2LC|DIVREDFCN:C2LCL|DIVREDFCN:C2RT|LVL:2|RED:2|REDTOT:2|REDNOFM:22|</font>


  •  You win.



  • Critical hit... it's super effective!


Log in to reply