- 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
Brillant! Very enterprisey, and it adheres to "best practices" (like the Factory pattern).
Although this wonderful solution is still lacking punctuation. If it weren't for that, I would immediately adopt it into my own code.
Admin
Even this can sometimes (rarely) be justified.
If you are driving a GPIO as an output, the physical level you are driving on the line and the logical value that it represents don't always match up. So you might need to set the output to 1 in order to actually send a ZERO.
The often-mentioned embedded systems are where you would be most likely to run into this sort of thing.
Admin
No, sleep is there, but not in the String class. Try java.lang.Thread.
Admin
If you think this is a WTF, your code is probably strewn with string literals, and because of this, bug-ridden.
These are apparently business objects that happen to 1 character in length. Would you use string literals everywhere if the strings were 2 characters long? What about 5? Why is it different because they are 1 character long?
Admin
Exactly what I was thinking.
Admin
He should have stored those values in a database table.
Admin
This design would never hold up at the Enterprise level. Two major failings:
EDIT: wrong button... meant to quote this: "That's actually pretty clever, in this way one can use inheritance to, I don't know, change the string associated to each letter. But it'd be better to dynamically generate this code through a SQL query, and embed the query into a PHP script. Then I'd write a small VB script piloting the cursor and the keyboard buffer in order to open Access, write the SQL query and launch it automatically. "
Admin
I agree. XML deserves to pay for everyone's pain and suffering.
Admin
Yes it can be much worse:
Public class Class extends EnterpriseRulesEngine { enum Letter { A, B, C, D... }; enum Number {1,2,3,4,5...}; } ...
Admin
For the love of all that has any meaning... please tell me this insanity stopped at 9...
In case the grenade hasn't gone off yet, that is to say that ,for example, 105 would be represented by ONE ZERO FIVE and not ONEHUNDREDFIVE.
Admin
Perfect just in case the alphabet evolves!
http://i.imgur.com/MMlkg.gif
Admin
No, that would be TENFIVE.
Admin
So that's what a brain hemorrhage feels like.
Admin
Glad we're isolated in case zero or one change their numeric values...
You know the rule... no magic numbers in the code! We'll be damned if were going to let this mysterious '0' and '1' slip through when we can just as easily use semantically descriptive constants.
Admin
That's a very clever way to get around the problem of "I can't tell whether this is supposed to be a zero or an uppercase oh, and whether that's a one or a lowercase ell".
Admin
A more clever way would be to use a font that doesn't suck.
Admin
Don't you want eth (not thorn) in "that" and "the"? I guess this might vary by language, I'm only familiar with Icelandic.
(Disclaimer: I'm not familiar with Icelandic.)
Admin
Настоящие программисты не используют Prompt!
Admin
Admin
I think the naming convention is wrong here but I don't do C# much.
Admin
Admin
Your wrongness isn't limited to naming conventions.
Here are the rest of your mistakes: -everything in your post
Admin
You have to use the classes in System.Reflection to extract the constants. That way, your snooping competitors can't get at them!
Admin
At my work, we have definitions like #define TRUE 0 #define FALSE 1
Just to confuse everyone.
Admin
I am going to start taking the bus from now on :-s
Admin
Fail! Punctuation marks obviously weren't on that guy's priority list.
Admin
Hey, if you're gonna translate the code, you might as well translate the alphabet (at least halfway):
ClassTypeA = 'А'; ClassTypeB = 'Б'; ClassTypeC = 'С'; ClassTypeD = 'Д'; ClassTypeE = 'И'; ClassTypeF = 'Ф'; ClassTypeG = 'ДЖ'; ...
Admin
Actually, C# has a readonly keyword which is the equivalent of java's final keyword. (static is the same in both cases) The const keyword is different from static readonly: it's handled at compile time, not run time. As a result, changing a const value means you have to recompile every file that uses it. private const is generally fine, but public const should generally be static readonly instead, unless you're sure the value won't change.
Admin
Admin
Nice lecture, but the reason Anon posted the code was because they already knew all that. Read the first sentence again: "I've seen something similar"
Admin
Can you use this to write alphabet spaghetti code?
Admin
FTFY.
Admin
Admin
That's true. You never know when people will add another letter to the alphabet.
Admin
Really? This is the only WTF in that code?
Surely this is just a precursor to a truly worthy WTF. All joking aside, what sort of bastard codebase has the need of this class hierarchy?
Or is this just lifted from sample code from the GOF's Flyweight pattern?
Admin
Excellent. Every enterprise system needs redundancy.
Admin
Happy Blogiversery!
TDWTF = Brilliant!
By the way, would you please stop discrediting my company's name!
Thankyou.
Paula Bean CTO Innotech Corp.
Admin
Admin
CommentTypeWTF
Admin
Admin
what about
#define File_Not_Found NaN
Admin
Admin
care-bear, you made my day!
Admin
I DONT SEE ANY PROBLEM WITH THIS IT DOESNT NEED LOWER CASE AS NOBODY USES THEM AND PUNCTUATION IS ONLY FOR PEOPLE WHO NEED TO BREATHE WHEN TALKING
LOUD HOWARD
Admin
At least this is NOT common practice on embedded devices with no filesystem...or is it? :-S
Admin
Admin
No no no. Use the stringification operator, just define your macros as X(A) X(B) etc, then:
#define X(a) a, enum LETTER { LETTER_TABLE }; #undef X
#define X(a) #a, char *letter_name[] = { LETTER_TABLE }; #undef X
MUCH better.
Admin
This piece of code would make perfect sense if the USA decided to change all abbreviations of US states to single upper-case letters.
Obviously, there is the small issue that there are 50 US states (and then some oddities like the District of Columbia), and only 26 upper-case letters, but this could be solved by using accents, or special Icelandic characters.
"A man from Houston, Ǽ, was interviewed by the police in connection with the investigation into bad coding practices."
Makes perfect sense.
Admin
Admin