• Max (unregistered)

    On the WTF grading scale, this one is about 5 milliPaulaBeans, which is a pretty damn good WTF.

  • (cs)

    Good lord, I think this is a PHP implementation of a block cipher from hell.

  • (cs)

    Geez that made my eyes hurt.

  • Shao Kahn (unregistered)

    FATALITY!

  • Larry (unregistered) in reply to Buddy
    Brian W. Kernighan:
    Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
    Anybody know this Kernighan guy? He sounds pretty smart. Maybe I'd like to hire him. Does he know VB?
  • SeanJA (unregistered)

    I'd say that trwtf is that they are using smarty... but the rest of it is pretty bad too.

  • Quirkafleeg (unregistered) in reply to Patryk Zawadzki
    Patryk Zawadzki:
    […] At least I assume that's why several of the former maintainers were found missing with only one quote left behind: “oh my God—it's full of stars!”.
    Really.
  • (cs) in reply to m a t t
    m a t t:
    Doesn't that make it difficult to run queries against? If the business really has that many flags on an object, then it is only sensible to slap them [...]
    I heartily endorse this course of action.
  • (cs)

    This is a great example to keep on hand for people who say "If it ain't broke, don't fix it." This code (presumably) works but is completely unmaintainable, unreadable, and immoral.

    It would be a soul-crushing, morale-sapping task to fix a bug, much less add an enhancement. It would be more pleasurable to maintain if they replaced it with:

    while (0<1)
    {
        spKickMeInTheBalls(repeatedly)
    }
    
  • AnOldRelic (unregistered) in reply to Patryk Zawadzki
    Patryk Zawadzki:
    You can write good code in a shitty language and shitty code in a great language. I've seen my share of WTF in my beloved Python. Don't blame the tools.
    I am most certainly going to blame the tools that actually sit and write this kind of code! But I agree, can't blame the language/IDE.
  • Brendan (unregistered) in reply to Halo

    Hi,

    Halo:
    Microsoft SQL Server supports the BIT data type which can represent either 0 or 1. These are stored internally within the table as bitmasks so that up to 8 of these columns will occupy only a single byte for as many of the columns as you want.

    That sounds entirely useless to me - sooner or later you need to add "File not found" to your true/false and then you'll wish you used a string of ASCII '1' and 0' (and 'F') characters...

    -Brendan

  • Procedural (unregistered) in reply to RBoy
    RBoy:
    procedural:
    (A different) Mike:
    Procedural:
    Mike:
    I stopped reading halfway down. If I had a job that involved this code, my next words would be "I quit".

    Ah, the generic throwaway comment; how appreciated.

    Two things:

    1. Hmmm, no you wouldn't; I'm sure it sounds great to say it at the brewery with the boys (or muttering on the sofa at night in front of the telly), but in reality, no you wouldn't.

    2. If you did you wouldn't be worth employing anyway; this code needs refactoring. Do you not consider refactoring part of your job ? Do you only take jobs to fix and improve code that is already good ? Perhaps you can't reengineer your way out of a few lines of code ? What good are you to a project then ?

    I propose that we relabel all the "I'd quit" posters that pollute every single darn story as incompetent and lazy prima donnas. Take up gardening or something.

    At least the original poster only wasted 2 seconds of our lives with his comment. That's a lot less time than I wasted reading your overwrought and totally unnecessary over-analysis of it. Just something for you to consider next time you're thinking of rebutting a useless comment with a considerably longer useless comment.

    Nah, definitely the same Mike. Go back to work.

    I doubt it, as I think you are quite the twit as well.

    Of course, only a prima donna would think that there's only one person in the world who doesn't agree with you.

    Well, if I am the only one who is annoyed at the repeated and demeaning statement that we developers should have the work ethic of a stoned slob, then so be it. It unnerves me to no end. If you had pride in your work and profession, it would annoy you as well. You disagree ? It's your right; and your brand.

  • Jeff (unregistered)

    Wow... just, Wow. You can't make this up folks. +5 for today's WTF! Great post Alex!

  • Edward Royce (unregistered)

    Hmmmm

    You know this reminds me of old RPG (Report Program Generator) from IBM. The reason being that RPG supported 99 "indicators" which were boolean state flags with a value of 0 or 1. Using these state flags you could activate or deactivate specific lines and blocks of code.

    But hey nothing surprises me anymore. I've some insane code and ridiculous designs. After a few years all you can do is shrug your shoulders and go "meh".

    meh.

  • Ted (unregistered)

    OH GOD, MY EYES. THEY'RE BLEEDING.

  • Skilldrick (unregistered)

    I wanna program like that when I'm older!

  • (cs) in reply to David Hamilton
    David Hamilton:
    David Hamilton:
    Just because you can do it that way doesn't mean that you should.
    Actually, a quick glance at the code shows the data is clearly structured into a number of groups of pairs of data:
    77-81 and 01-14
    15-20 and 21-24
    43-45 and 46
    47-49 and 50-51
    52-53 and 54-55
    56-57 and 58-59
    plus 25-41 used in the query
    In other words: That data could (and should) have been broken up into several data columns to make it supportable.
    Seriously? Your first response on seeing this was "I just need to normalize it"?
  • (cs) in reply to Procedural
    Procedural:
    Mike:
    I stopped reading halfway down. If I had a job that involved this code, my next words would be "I quit".

    Ah, the generic throwaway comment; how appreciated.

    Two things:

    1. Hmmm, no you wouldn't; I'm sure it sounds great to say it at the brewery with the boys (or muttering on the sofa at night in front of the telly), but in reality, no you wouldn't.

    Hmmm, gotta disagree with you here. For starters, you seem to be oblivious to the notion of figures of speech. "I quit" is simply an expression demonstrating disgust at something (in this case, the submitted WTF). That you took it so literally to bang someone in the head with it speaks more about you than anyone else.

    Secondly, if we were to take the figure of speech so literally, you are assuming everyone is in a position where quitting is not an option (surprise! some do have that option.) Also, you seem to believe refactoring is something that you can simply do to any code base. Wrong.

    Software development is much more than code writing. It is a creative and business and engineering process. From experience, you have to have a heck of good co-worker and management support to tackle that kind of crap (.ie. good org inheriting or supporting uber-crap legacy.) There you have an ethical reason to plow away.

    Also, from experience (sadly and painfully so), if that kind of code is the active product of a team and organization, chances are that they are equally convoluted and inept (or more so). Under those conditions, quitting is a sane alternative. Here, you do not have an ethical reason to do so, and only a moron would stay there stagnant.

    Furthermore, there is a type of code (and people behind it) for which "I quit" is the only sensible solution. The 2nd law of thermodynamics applies to software as well. Not knowing anything else, that code looks like a good candidate for throwing your hands up.

    Procedural:
    2. If you did you wouldn't be worth employing anyway; this code needs refactoring.

    Not all code needs/deserves refactoring. This is a known fact in software. Refactoring is not a magic keyword that can turn all things wretched into usable things, not without costs. Refactoring is done when it is tactically/strategically sound, when the cost/gain ratio of its incremental application is acceptable. You need to have an underlying architecture and design that can be exploited and improved upon with re-factoring.

    Chances are, that code snippet is representative of an entire system. Attempting to refactoring it is akin to putting neosporin on a melanoma.

    Procedural:
    Do you not consider refactoring part of your job ? Do you only take jobs to fix and improve code that is already good ? Perhaps you can't reengineer your way out of a few lines of code ? What good are you to a project then ?

    The first three questions are gratuitous ad hominems and strawmen. You took someone light-hearted comment ("I quit"), twisted it into an argument he didn't make ("I don't believe in refactoring"), constructed a counter-argument ("re-factoring is important"), and then used it to hit the man with you e-weewee ("re-factoring good, u sux") with which to implicitly state your l33t hax0r status...

    ... how does that work for you?

    The fourth question gives me the impression you are simply projecting or are out trying to prove something.

    Procedural:
    I propose that we relabel all the "I'd quit" posters that pollute every single darn story as incompetent and lazy prima donnas. Take up gardening or something.

    I propose we create custom labels that read "I project my own baggage (calling people prima dones in the process), I build strawman arguments, and I like to lecture people about refactoring even though I don't quite understand the conditions in which it is applicable." How about that?

  • ARMed but harmless (unregistered)

    IT'S ALIVE!!1!!

    Seriously, if code becomes sentinent and starts to expand itself, the result will look exactly like this.

  • ARMed but harmless (unregistered) in reply to Skilldrick
    Skilldrick:
    I wanna program like that when I'm older!

    I am hoping to be dead long before I get that old.

  • Grumpy (unregistered)

    bam Headshot!

    What a thoroughly evil "snippet" of code...

  • BenHead (unregistered)

    And I thought the system I had to work on (and thankfully eventually redesign) was bad for storing a GUID in an nvarchar(38) field! (Yes, unicode, yes, variable-length, yes, it included the hyphens and curly-braces.)

  • Aaron harun (unregistered)

    Usually, I try to make sense of the crazy, but, for this one, not even going to bother.

  • Not You (unregistered)

    I see several valiant efforts to describe this code in the comments here, but they've all fallen short. The correct description is:

    OH GOD, IT BURNS!

  • LOLer (unregistered) in reply to Jay
    Jay:
    (A different) Mike:
    Procedural:
    Mike:
    I stopped reading halfway down. If I had a job that involved this code, my next words would be "I quit".

    Ah, the generic throwaway comment; how appreciated.

    Two things:

    1. Hmmm, no you wouldn't; I'm sure it sounds great to say it at the brewery with the boys (or muttering on the sofa at night in front of the telly), but in reality, no you wouldn't.

    2. If you did you wouldn't be worth employing anyway; this code needs refactoring. Do you not consider refactoring part of your job ? Do you only take jobs to fix and improve code that is already good ? Perhaps you can't reengineer your way out of a few lines of code ? What good are you to a project then ?

    I propose that we relabel all the "I'd quit" posters that pollute every single darn story as incompetent and lazy prima donnas. Take up gardening or something.

    At least the original poster only wasted 2 seconds of our lives with his comment. That's a lot less time than I wasted reading your overwrought and totally unnecessary over-analysis of it. Just something for you to consider next time you're thinking of rebutting a useless comment with a considerably longer useless comment.
    Ouch, burned. But for the record I agree, can't bitch about useless comments when you're making one yourself.

    LOL! Good one.

  • (cs) in reply to Little Bobby Tables
    Little Bobby Tables:
    There are 10 types of people in this world..

    Those who know how many periods make up an ellipsis, and those who don't?

  • jjs (unregistered) in reply to tristique
    tristique:
    jjs:
    Zylon:
    <comment redcated>
    <reply redacted>
    <defense of original poster's comment redacted>
    <scathing rebuttal and suggestion that defender's mother is a whore redacted>
  • 10kind (unregistered)

    Where the f did you find my code^^

  • darkmage0707077 (unregistered) in reply to Skilldrick

    Timmy! That's not nice! I want you to go to your room and just THINK about what you just said! And there'll be no desert for you tonight, either!

  • Kryten (unregistered)

    There's an old android saying which I believe is peculiarly appropriate here. In binary language it goes something like this: 001100111011000111100, which roughly translated means, "Don't stand around jabbering when you're in mortal danger."

  • Some Jerk (unregistered)

    Perfectly sane uses for perfectly insane code:

    1. Sending the coding team into fits of convulsions, thereby increasing the demand for programmers and logically increasing average programmer salary.

    2. Competing with offshore markets in the area of cpu and memory usage for simple applications.

    3. Convincing aliens not to invade earth for lack of intelligent life forms.

    4. Creating hidden hacker access through obscure and seemingly arbitrary chaos.

    I think that any company infrastructure that allows such code to be produced and written and maintained obviously performs insufficient code review against their developers and deserves the misfortunes that comes with it. On the other hand... I pitty the poor fool that has to attempt to scratch a living at such a place, maintaining said grabage each day. I would upload a beer if it could be reduced to binary digits and compressed into a string for you.

  • Procedural (unregistered) in reply to luis.espinal
    luis.espinal:
    Procedural:
    Mike:
    I stopped reading halfway down. If I had a job that involved this code, my next words would be "I quit".

    Ah, the generic throwaway comment; how appreciated.

    Two things:

    1. Hmmm, no you wouldn't; I'm sure it sounds great to say it at the brewery with the boys (or muttering on the sofa at night in front of the telly), but in reality, no you wouldn't.

    Hmmm, gotta disagree with you here. You are assuming everyone is in a position where quitting is not an option (surprise! some do have that option.) Also, you seem to believe refactoring is something that you can simply do to any code base. Wrong.

    Software development is much more than code writing. It is a creative and business and engineering process. From experience, you have to have a heck of good co-worker and management support to tackle that kind of crap (.ie. good org inheriting or supporting uber-crap legacy.) There you have an ethical reason to plow away.

    Also, from experience (sadly and painfully so), if that kind of code is the active product of a team and organization, chances are that they are equally convoluted and inept (or more so). Under those conditions, quitting is a sane alternative. Here, you do not have an ethical reason to do so, and only a moron would stay there stagnant.

    Furthermore, there is a type of code (and people behind it) for which "I quit" is the only sensible solution. The 2nd law of thermodynamics applies to software as well. Not knowing anything else, that code looks like a good candidate for throwing your hands up.

    Procedural:
    2. If you did you wouldn't be worth employing anyway; this code needs refactoring.

    Not all code needs/deserves refactoring. This is a known fact in software. Refactoring is not a magic keyword that can turn all things wretched into usable things, not without costs. Refactoring is done when it is tactically/strategically sound, when the cost/gain ratio of its incremental application is acceptable. You need to have an underlying architecture and design that can be exploited and improved upon with re-factoring.

    Chances are, that code snippet is representative of an entire system. Attempting to refactoring it is akin to putting neosporin on a melanoma.

    Procedural:
    Do you not consider refactoring part of your job ? Do you only take jobs to fix and improve code that is already good ? Perhaps you can't reengineer your way out of a few lines of code ? What good are you to a project then ?

    The first three questions are gratuitous ad hominems and strawmen. You took someone light-hearted comment ("I quit"), twisted it into an argument he didn't make ("I don't believe in refactoring"), constructed a counter-argument ("re-factoring is important"), and then used it to hit the man with you e-weewee ("re-factoring good, u sux") with which to implicitly state your l33t hax0r status...

    ... how does that work for you?

    The fourth question gives me the impression you are simply projecting or are out trying to prove something.

    Procedural:
    I propose that we relabel all the "I'd quit" posters that pollute every single darn story as incompetent and lazy prima donnas. Take up gardening or something.

    I propose we create custom labels that read "I project my own baggage (calling people prima dones in the process), I build strawman arguments, and I like to lecture people about refactoring even though I don't quite understand the conditions in which it is applicable." How about that?

    Yup, you are right; there is a lot of baggage being projected today. I used to work at this place I loved. The two owners were fantastic people; one a great PM, one a very creative and deeply knowledgeable developer. They had been a unit for years and years. This was their business; no venture capital, no loans, just growing through cash flow. That's a rarity nowadays. The product was awesome. It had grown a bit spaghetti-like over time but everyone chipped in when demand grew to stabilize the codebase, refactor it, and make it so it would be able to evolve through subsequent code generations. We all chipped in; long hours, downright courageous attacks of huge slabs of code, no budget. It was hard work but some of the best work I've ever seen done. The product was eventually taken over by another company who replaced the original team by a bunch of code-patchers who messed up the product pretty badly, preferring an "I quit"/"let's delay good coding"/"it was like that when I came in"/"sell that patch to management"/"take no initiative" mentality to continuing on good principles and code (given, as you mentioned, the proper costs).

    I've been in the dev biz for 31 years; I am starting to know people who reach retirement and pass away. Sometimes the people who take over their code threat it like it is their own adopted baby, respect it, make it grow, yet rebuilt it in better form as necessary. But often slobby short-termers show up and turn great code into bad. I hope that all the code we've written will pass on as legacy, as the start of something much bigger and better in the future, reengineered, transcoded, refactored if you will, yet relentlessly improved upon. This matters. People before us were not all dumb, and their work wasn't just "man-hours". It was real work, real love, real craft, real intelligence being stretched and worked upon. So when I see people who look at a few hundred lines of code and presume that this is such a hard challenge that they do not feel up to it (or up to selling the task on its value above and around them), it scares the hell out of me. It's okay when it happens once in a while but lately the "I quit" routine has been the punchline or amongst the first unchallenged comments in a long series of posts. It is just as major a statement of mediocrity as the WTF itself. I contrast this attitude to that of the great coders I know, young and old, and I wonder if there's enough of them to make up for the others.

    Here the code above could be anything; it could be a local issue caused by a new developer tasked with moving old green-screen code to a new environment. It doesn't mean that the whole code is bad; it may have taken a dip with that person for whatever reason (lack of available talent, rush to market, etc.), but beyond the surface crud could be a sound structure. Or it could be genuinely representative of terrible code throughout. Who knows. We don't see the whole story. The commenter also didn't, but the response was unmistakably biased towards mediocrity, and this is what I responded to.

    I am sore today because I learned of the death of one of the cofounders, and looked upon their legacy and saw it wasted by greed, poor ethics and ineptitude. I wish we were all prouder of our profession, even when doing work that is either technically hard or a tough institutional sell, that's all.

    (Bye H.G.)

  • Josh (unregistered)

    That code sample made my brain sad.

  • penis (unregistered)

    penis

    CAPTCHA: eros Damn right

  • (cs)

    GROK completed.

  • (cs) in reply to Josh

    I have a plan to turn this around for some good. I think its a good one.

    That audio blog version of this site? Well, once the guy who narrates it gets it posted (a task which will end up on some DailyWTF-style site for people that work in that industry, no doubt), I am going to record it and burn it to a CD.

    That CD will go in to the alarm clock.

  • Jordan (unregistered) in reply to Aaron

    If you use PHP to talk to a SQL Server database, the functions used are all the same as the mysql functions, but they write mssql instead. So mssql_query($qr, $conn) sends a query to a SQL Server database.

  • hoho! (unregistered) in reply to FragFrog
    FragFrog:
    OzPeter:
    The sample strings are 82 bits long. I did a cursory search on google and I can't see any popular DB (MSSQL, MySQL or Orace) that supports 96 bit integers.
    I know for a fact MySQL supports binary data columns and it would greatly surprise me if all other database environments did not have similar data types. One would normally use them for storying binary data (like images if you are an idiot) but they would do well enough for bitmasks. Provided you need more than 31 masks of course, which in and of itself is already quite a WTF.

    As usual, TRWTF is in the comments... how many bits in a 32-bit word, again, Albert?

  • Vox Simpleton (unregistered)

    I knew this wasn't my code as soon as I saw the reference to Smarty templates!

  • (cs)

    This code could be used as a legal defense for killing puppies. Or at least grounds for an insanity plea...

  • Trebonius (unregistered) in reply to Aaron

    I'd say "MSSQL" is a fair name, since Microsoft neglected to name their product.

  • (cs)

    This code was written by a genius. Only a genius would be able to make sense of it.

  • (cs)

    "Consider "0010000000100000". It's a string filled with nothing but "1" and "0" characters. Now, unless such a string is part of some classroom assignment where the goal is to programmatically convert Based 2 to Base 10 — or, perhaps, existing in some highly-limited and/or perverted language like MUMPS — there is never a good reason for it to exist in a program."

    Why do database "programmers" think they know it all? THERE ARE GOOD REASONS for putting a string of 1s and 0s into the source of a program. I routinely did so for values where each bit represented the state of an output bit on an embedded controller. Thus at a glance when debugging code I knew what was expected of each bit on that port.

    I could just as easily have coded the value in hexadecimal or decimal, but then the value of each bit would not be obvious.

    Language? MUMPS? FoxPro? Good Lord, no. Good ol' C.

    Why is The Daily WTF so heavily overloaded with database "programmers"? Aren't there any real programmers here?

  • Steve-O (unregistered)

    I saw this, and nearly killed a random stranger thinking that he might have been the author.

  • (cs)

    Sigh. I can actually defend the storage part of this giant WTF (not the access part, it's pretty much indefensible).

    In the codebase I work with, there is a rare (sic!) case when we need to store a string of "01010000...101" in a varchar: we have to check if all parts of a certain message are loaded into the system before a linked document can be processed. Before you say "WTF", consider that a) the number of parts can be anywhere from 1 to 10 to (rarely/unpredictably) 300-something or more b) there are no SQL-joins or searches against the string c) a human has to be able to make the "complete/uncomplete" check at a glance in case of a loading/processing failure, and I'm not familiar with many humans who can easily tell what is missing when coding the flags as a 300-bit integer.

    Overall, with some additional tuning, it turned out to be a pretty good and scalable design. Which might not be the case here, of course.

    And those suggesting using over 80 separate columns... Seriously, don't.

  • blp (unregistered)

    A few days ago, I noticed this:

    http://radar.weather.gov/radar.php?rid=enx&product=N0R&overlay=11101111&loop=no

    The bool field in the overlay= maps to the checkboxes below the image.

  • (cs) in reply to jjs

    BURN IT

    No put that CD away, that's not what I meant!

    jjs:
    Zylon:
    <comment redcated>
    <reply redacted>
    And the clown said, <punchline redacted>!

  • (cs) in reply to SilentRunner
    SilentRunner:
    Why is The Daily WTF so heavily overloaded with database "programmers"? Aren't there any real programmers here?

    Hey, I'm a database programmer and still I know there may be a pretty good reason for "01101" to be a string and be stored as such (as I stated in my own comment above). We just have to face that on this blog, any part of a post can be a WTF =D

  • 00110011 (unregistered)

    1100000011000111110001100000011 1100110011001000001001100110011 1100110011001000001001100110011 1100110011001000001001100110011 0111001110000111110000111001110

  • (cs) in reply to SilentRunner
    SilentRunner:
    "Consider "0010000000100000". It's a string filled with nothing but "1" and "0" characters. Now, unless such a string is part of some classroom assignment where the goal is to programmatically convert Based 2 to Base 10 — or, perhaps, existing in some highly-limited and/or perverted language like MUMPS — there is never a good reason for it to exist in a program."

    Why do database "programmers" think they know it all? THERE ARE GOOD REASONS for putting a string of 1s and 0s into the source of a program. I routinely did so for values where each bit represented the state of an output bit on an embedded controller. Thus at a glance when debugging code I knew what was expected of each bit on that port.

    I could just as easily have coded the value in hexadecimal or decimal, but then the value of each bit would not be obvious.

    Language? MUMPS? FoxPro? Good Lord, no. Good ol' C.

    Why is The Daily WTF so heavily overloaded with database "programmers"? Aren't there any real programmers here?

    I don't know many "real" programmers who think it's OK to routinely expand data by a factor of 4 or 8. I also don't know many "real" programmers (or EEs for that matter) who don't know how to convert a hexidecimal character to it's binary nibble representation in their head.

Leave a comment on “1's and 0's”

Log In or post as a guest

Replying to comment #:

« Return to Article