- 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
On the WTF grading scale, this one is about 5 milliPaulaBeans, which is a pretty damn good WTF.
Admin
Good lord, I think this is a PHP implementation of a block cipher from hell.
Admin
Geez that made my eyes hurt.
Admin
FATALITY!
Admin
Admin
I'd say that trwtf is that they are using smarty... but the rest of it is pretty bad too.
Admin
Admin
Admin
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:
Admin
Admin
Hi,
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
Admin
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.
Admin
Wow... just, Wow. You can't make this up folks. +5 for today's WTF! Great post Alex!
Admin
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.
Admin
OH GOD, MY EYES. THEY'RE BLEEDING.
Admin
I wanna program like that when I'm older!
Admin
Admin
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.
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.
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.
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?
Admin
IT'S ALIVE!!1!!
Seriously, if code becomes sentinent and starts to expand itself, the result will look exactly like this.
Admin
I am hoping to be dead long before I get that old.
Admin
bam Headshot!
What a thoroughly evil "snippet" of code...
Admin
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.)
Admin
Usually, I try to make sense of the crazy, but, for this one, not even going to bother.
Admin
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!
Admin
LOL! Good one.
Admin
Those who know how many periods make up an ellipsis, and those who don't?
Admin
Admin
Where the f did you find my code^^
Admin
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!
Admin
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."
Admin
Perfectly sane uses for perfectly insane code:
Sending the coding team into fits of convulsions, thereby increasing the demand for programmers and logically increasing average programmer salary.
Competing with offshore markets in the area of cpu and memory usage for simple applications.
Convincing aliens not to invade earth for lack of intelligent life forms.
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.
Admin
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.)
Admin
That code sample made my brain sad.
Admin
penis
CAPTCHA: eros Damn right
Admin
GROK completed.
Admin
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.
Admin
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.
Admin
As usual, TRWTF is in the comments... how many bits in a 32-bit word, again, Albert?
Admin
I knew this wasn't my code as soon as I saw the reference to Smarty templates!
Admin
This code could be used as a legal defense for killing puppies. Or at least grounds for an insanity plea...
Admin
I'd say "MSSQL" is a fair name, since Microsoft neglected to name their product.
Admin
This code was written by a genius. Only a genius would be able to make sense of it.
Admin
"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?
Admin
I saw this, and nearly killed a random stranger thinking that he might have been the author.
Admin
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.
Admin
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.
Admin
BURN IT
No put that CD away, that's not what I meant!
And the clown said, <punchline redacted>!Admin
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
Admin
1100000011000111110001100000011 1100110011001000001001100110011 1100110011001000001001100110011 1100110011001000001001100110011 0111001110000111110000111001110
Admin
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.