- 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
Try to actually compile a full list of the hardware Sega sold. Just the home stuff, you don't have to count arcade machines. I find it to be mind-blowing.
Not only was the Nomad not the only portable Genesis (if you count the Mega Jet), but the Sega/Mega CD had at least six different models, the Genesis has had three or four. They allowed the Saturn to cannibalize 32X sales. Same with the DC and the Saturn.
Their "more is better" approach to hardware SKUs with infighting and actual sabotage happening between jealous divisions, and you have a series of WTFs worth of relegating even the mighty Dreamcast to history's junkheap.
Admin
Admin
The real WTF is the amount of people on here who can't agree on what the posted code actually does :D
Admin
Admin
St. is an abbreviation (whether for Street or Saint...)
WTF, IBM, LA, WCAB are all acronymns....
Admin
my brain hurts......
Admin
Admin
Oh the irony... Why would you bag people for correcting others and then jump in and make a correction yourself? I suppose as you said, pointing out how wrong everyone is is far more important than anything else....
(As already pointed out) Many (I would say most, but I can't confirm that) dictionaries do not share your view that Acronyms must be pronouncable words...
I'm not entirely sure that the pedantry really matters, one way or the other...
Admin
So IBM stands for International Machines Business?
Admin
Wait, doesn't PHP stand for "PHP Hypertext preprocessor"?
Admin
No it doesn't.... It has nothing to do with the X in AXMD, it has to do with the fact that XXX is one of those 'words'....
When 'XXX' is tested as a word, the program returns false (it never gets set true, because it only processes Xs)
Admin
This is the most asinine conversation that has occurred on planet earth today.
But, since you all take such pleasure from being insufferable know-it-alls, I can join in the fun.
The key lies in the etymology of the word (Greek). "Acro", from the Greek "akros", meaning tip, "onym", derived from "onoma", meaning name.
The implied meaning is that an acronym is then a Name based on the tip of a word. There is nothing in the etymology to suggest that pronunciation is relevant.
Ipso Facto, IBM is an acronym. Since an acronym is technically a type of abbreviation, IBM is also an abbreviation.
QED suckas.
Admin
It does for about the last 12 years...before that it actually stood for Personal Home Page.
A similar "recursive acronymn" is GNU = GNU's not Unix
Admin
Yeah, I willingly concede that when I originally posted the "Sure it'll work!" post, I was daftly assuming that the loop was checking an the acronym, not the meaning of the acronym.
The program of course fails if you have a string of all X's.
Admin
This example seems to illustrate three perversions. The definitions are stored as separate words, the normalization looks real wierd, and the table contains unnecessary group delimiters. But are these all really perverse?
Question one: did the original author have a good reason for storing the abbreviation definitions as separate words, or was he blundering about in total blindness?
Maybe he slept through his second hour of CSB102 and thus missed learning about spaces -- but maybe he had a vague reason for storing the definitions as separate words. E.g.:
(1) Maybe the data contains many related definitions like the WCAB example, and he hoped to encode something like this:
{WORK|WORKER'S|WORKMEN'S} {COMPENSATION} {APPEAL|APPEALS} {BOARD}
Defining a sort of regex structure like that would require breaking the definition into words or at least substrings. Unfortunately the author didn't have the skills to complete his mad design, or the time to undo his bizarre table structure.
(2) Maybe the original author slept through his second hour of CSB302 and thus missed learning about VARCHAR. Making a CHAR column wide enough for the longest anticipated definition would certainly waste an enormous lot of storage. So he defined the individual words in ABBR_TXT as buckets, and applied the first normal form. This is brillant if you think about it.
(3) Given the one-to-many relationship of abbreviations to definitions, the data is not obviously useful for translating abbreviations into their expanded phrases. It could, however, handily serve to translate common phrases into standardized abbreviations. Perhaps you can see how a secondary index on ABBR_TXT could be used in a sophisticated search algorithm to quickly identify all possible abbreviations containing each word in the target phrase.
Or perhaps not. I sure can't.
Question two: is the current table structure the result of many careful successive refinements, or did the developer just stop messing with it as soon as it seemed to work?
Given that the definitions will be stored a separate words, the table structure is perfect. Of course the column order does hint at a somewhat convoluted history of design -- one can only blanch at the thought of what early versions of this table must have looked like -- but it works fine now.
ROWID int -- primary index; secondary index column 3 ABBR_CDE char 15 -- secondary index column 1 ABBR_IDX int -- secondary index column 2 ABBR_TXT char 30
Range on ABBR_CDE: all the words in all the definitions for a specific abbreviation.
Range on ABBR_CDE, group on ABBR_IDX: all the words in each separate definition for a specific abbreviation.
Range on ABBR_CDE, group on ABBR_IDX, sort on ROWID: all the definitions for a specific abbreviation.
I ask you, what more could you want?
Question three: Can there ever possibly be any excuse for a record group delimiter?
A complete failure of truly epic calibre. It does, however, provide definitive answers to questions one and two.
-Harrow.
Admin
Admin
People Can't Memorize Computer Industry Acronyms
(or Abbreviations, if you wish)
Admin
Admin
What more could I want? The truth perhaps. Based on your ranges, it looks like quite a few acronyms also mean "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX."
Admin
uh... I am a MENSA type but I also refer to it as IBM... o_O
Admin
One possibility is that this started life as a flat file (without the ABBR_IDX column at the end), and the delimiters were used more or less sanely to indicate the end of a particular meaning for the current abbreviation. (Breaking it up into words is still a WTF though - in fact, even more in this case because it couldn't have been for indexing purposes.)
Then, at some later point, the contents of the flat file were dumped into a database table. Hopefully the ABBR_IDX column was added at the same time because they realised they couldn't depend on rows being read out in any particular order. But I wouldn't bet money on it. They certainly didn't realise that the correct procedure would be to increment ABBR_IDX when you see the delimiter but not pass that row through to the database.
Or, of course, they could have been smoking something particularly noxious the whole time they were doing the database design. It's hard to tell.
Admin
private static boolean isNotAllXs( String s ) { StringBuffer test = new StringBuffer( s.trim() );
boolean retVal = test.Length() == 0 ? true : false;
for ( int i = 0; i < test.length(); i++ ) { if ( test.charAt( i ) != 'X' ) { retVal = true; break; } } return retVal; }
Admin
Admin
So many of the WTFs I see are old hat - some stupid algo dreamed up by somebody with 1 year of experience (that I remember implementing myself years ago) or somesuch.
But every so often, I see a real, true, bonafide WTF. Somebody who is obviously, painstakingly, and carefully taking a clearly good idea and implementing it in the worst possibly imaginable way.
This isn't one of the very best WTFs, those are reserved for those WTFs that work at multiple levels, where WTFs stack on top of each other like people in a cheap pornographic orgy video.
But this, folks, is a real, true, bona-fide WTF. A true over-normalization!
I guess you could call this 3rd^3 degree of normalization? It might be better if you implemented a linked list as a normalized database entry!??
I could just see the schema now:
create table wtfwtfwtf(thecharacter varchar(1), thesequence integer not null, thestringID integer primary key, unique(sequence, stringID));
Enjoy! I sure did!
Admin
Go (SELECT abbr_txt FROM wtf_table WHERE rowid = 8413) yourselves!
Admin
If that is the only thing coming to your mind after reading about this code abomination - I really envy you!
Admin
Please disregard last post. After my first sip of coffee I got it. ;-)
Admin
SQL specifies LIKE operator and some wildcard characters for that. Still a WTF.
Admin
I'm having a hard time seeing why the submitter of the story would opt for a DAL object and hashmap and keep the WTF in the background instead of converting the table to a sane normalized one. If he could create a new DAL for people to use I'm sure he could just sort the table out aswell.
Admin
But then he'd have to write a reverse interface layer for existing code using the database in a non-abstracted way, and change existing code that was probably specifying SQL directly.
Of course, once all code is using the new abstract hash-based interface, the DB-level implementation can be swapped out with minimal impact. But only once all code is using it...
Admin
130 comments, and nobody's brought up regular expressions yet (except Harrow's harrowing drive-by miss)? Shame on you all.
public static bool isDelimiter(string testValue) { return Regex.Matches(testValue, "^X{30}$").Count != 0; }
Admin
Admin
public static bool isDelimiter(string testValue) { return testValue == "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; }
Admin
Admin
Admin
public static bool isDelimiter(string testValue) { if (testValue.length() < 20) return false; for (char c: testValue.toCharArray()) if (c != 'X') return false; }
I learned Java in the 1.4 days before they implemented foreach loops, and haven't written it for several years so I'm not sure if you could just iterate through the string rather than ocnverting it to a char array; but at least this version short circuits, is easy to understand, and deals with edge cases where either: a short string of Xs could be a legitimate part of the name, or someone has misentered the delimiter, by accepting any string of Xs longer than 19 as a valid delimiter.
Now, who's going to be the first to flame me for use of magic numbers? ;^)
Admin
Of course you could write
int isntallx(char *s) { while(*s == 'x') s++; return *s != '\0'; }
this seems better than an earlier solution that appeared to copy the string into dynamic memory (having, presumably, worked out its length), then trimmed it, and then had a further go at working out the length before finally getting down to examining the characters.
BTW when I first read the WTF - I thought the reference was to "-2nd" normal form (with a negative sign) which seemed seriously appropriate to this comedy.
Admin
Okay, granted somebody could enter 29 instead of 30 X's, or miss a shift key (assuming they were stupid enough not to set shift to uppercase before typing 30 X's). My take on that is, if they can't double-check their input, let the system crash and burn when they try to look up an Acrophony.
Admin
as has already been pointed out, such a construct is likely to result in a search that doesn't use an index. not scalable.
and the reliance on the LIKE operator is likely to introduce subtle bugs. what if you want to find acronyms that use the word 'in' but not 'international', 'internationalized', 'begin', and myriad other variations? your simple LIKE is getting more complex.
Admin
I would say it's apparent from your comment that you don't know normalization as well as you think.
for instance, what business reason would you propose for using 3NF, but not 4NF? what about 5NF?
can you specify plausible business rules for the design in the original article that imply it's in 2NF but not 3NF?
Admin
Admin
If he's black? Bouy.
</RaciallyInsensitiveJokes>Admin
$ acronynm PHP Segmentation Fault
Hmm... the acronym looker-upper stopped working.
Admin
Not to mention he broke the original implementation. What if I use "XXXXX" instead?
Admin
Noooooo. Once retval is set true, there is never another chance to be set back to false. It returns true for XXXXXXXXXXAXXXXXXXXXXXXXXXXXXX
Admin
There's no point calling him. Just go and get him.
Admin
I thought this looked more like What The Form. But the negative 2nd normal form is good too.
Admin
Admin
Yo mst be from the nited States of America...
Admin
2NF is not 'Normalized', it's stupidity in almost 100% of the cases in which it is implemented. This is one of those cases, without a doubt.