- 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
Holy hell, this really did make me go "WTF?!"
Admin
Ah, the generic throwaway comment; how appreciated.
Two things:
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.
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.
Admin
for anyone wondering wtf all that binary shite is, my guess is someone in management wanted a html grid of check boxes to click turning products on and off (as well as some product features?). A the db architecture was probably never designed properly so they had to shoehorn some kludge into hold lots of meta data into it.
Admin
If you type MSSQL into google, the top of the list is a Microsoft SQL Server home page. And if you can't spot the Oracle typo for what it is then there is not help for you.
Admin
Nah, they'd stop at the first bit of weed, take out their lace umbrellas, and declare in operatic tones: "Blasphemy ! This garden has weeds ! I quit !". So, no go for gardening. You need something that doesn't require any effort.
Admin
And yes. Everything is better when its a string
Admin
Maybe not limited. It's certainly still widely in use for a reason other than people just don't know how to get out of using it (which happens a lot, as we all know COUGHCOBOL**COUGH) but you can't say it's not perverted.
Admin
Admin
What's a "redcated" table name?
Admin
This code is OVER 9000!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Captcha: facilisi, Facist Pasta
Admin
Oh come on! This isn't a WTF. It's definitely an OMFG.
Admin
It's obvious that the original code used "." and "*", replaced by "0" and "1" during the entry anonymization process.
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!”.
Admin
Admin
DAAAH!!! It burns! My eyes! Wow, and I thought VisualFoxPro was bad.
Admin
Admin
Admin
Admin
Apparently back in the distant past they used 0 and 1's to represent data. These days of course we use bytes as they are much more understandable.
Admin
Oh it's PHP... what a surprise. Years ago every newbie was producing similar "gems" in VB... now it's PHP
Admin
Wow, this is truly a WTF!
Jani and Alex, thanks for sharing this marvelously grotesque masterpiece.
Admin
I would so love to hear this post done by Hear a blog. That would be some awesome listening!
Admin
Admin
Nah, definitely the same Mike. Go back to work.
Admin
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.
Admin
TRWTF is all those $i != conditions and then a further check against the array!
It also looks like there's a huge if/else with similar code in both conditions; maybe they're the same... There's too much code bother comparing ;-D
Admin
Oh yes there is - 'Orace at least: http://myspeccy.com/en/games/horace-goes-skiing
Admin
Well, one should at least put hex code on that varchar, to simplify reading, and reduce storage space. But that wouldn't simplify the code... For that, one'd need to use a big integer class/type/whatever, instead of the regex nonsense. Or better yet, why the hell does it need that amount of booleans? (Those are booleans, aren't they?)
Well, if you are talking about PHP5, you have a point. Earlier versions were so bad, that I doubt they could be put to good use. Bad languages atract bad coders, and those don't simply go away when you improve it, but keep compatibility.
Admin
ZZzzzz...
Admin
Admin
Admin
if code works... that guy is a genius ;-)
Admin
TRWTF is that this code is covered by an NDA. You will be hearing from our lawyers.
Admin
Me uncle 'Orace ain't gonna like bein' tol' 'e don't 'zist.
Admin
I've seen one real-world scenario that does something approximating justifying concatenated strings in a varchar (at least I assume it was a varchar underneath, I didn't actually look.) This was an ERP system meant to be field configurable to whatever was wanted. The actual handling of the product IDs was a very long string that contained all the information to describe any given item. Items for which the strings matched were identical, if they didn't match they weren't.
The reason the strings made some sense is that as you progressed down the expansion from the ordered product to all the bits that made it up you didn't need the same fields at each point. This made trying to build sensible database fields hard--the program needed to generically manipulate data whose structure changed. Thus each type of item had it's own mapping instructions that could extract fields from the string.
While it would be unlikely to contain a block of booleans it's the same basic concept.
Admin
Admin
Admin
Admin
well, embedded systems don't have filesystems so they cannot store anything besides 0s and 1s
Admin
Man, I love when articles make me feel like a good programmer. It's great for the self-esteem to be able to look at something and say "Man, I've done some dumb shit in my time, but holy hell I've never done anything THAT bad."
Admin
Looking at the code snippet, it appears as though most of the values are zero. I'd look at saving only "1" values in a redesigned schema. For example, only a few columns with the identifier of the "1" field as one of them.
E.g.
Becomes:
A few methods to abstract out, and then a chunk of business logic where all the ugly dependencies can go. If the dependencies are linked logically, say like components of an assembly, then those can be represented in the DB too.
I've seen lots of code like this, the cause is usually a rushed developer against tight deadlines. The end result is the evolution of a logical temporary hack into a monster.
Admin
Admin
If he can debug it, he's a super genius!
Admin
At least this code fragment is self-explanatory. The code is so well-structured that any comments would be superfluous.
Admin
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. In this case it would mean 82 different columns but it would also mean that querying individual values are very simple. Also, technically the BIT data type can be treated as a ternary type as it can be NULLable, with NULL being tracked within the bitmask in the row header.
Also, all of these DBs generally support NUMERIC(x) or DECIMAL(x) for integral values larger than any specific bit-ness. NUMERIC(25) would be sufficient to hold a bitmask of 82 values, assuming the client application can work with such values. However, in those cases it probably would be better to use multiple 32-bit or 64-bit integral fields and to handle them as separate bitmasks. You'd need to understand the order of the values within the bitmasks anyway so no real additional burden is involved with splitting it across multiple bitmask values.
Admin
Egads... I could just imagine TopCod3r's justification for this...
It's enough to make Mara cry.
Admin
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.
Admin
Admin
I think I saw a 2...
Admin
Google: Did you mean: redacted Top 2 results shown
Admin
Something inside of me died after reading this.