- 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
"H" and "O" are uppercase - because reasons, obviously.
Admin
I see no huge problem with setting the enum values the match ASCII letters. TRWTF is redefining the whole alphabet as an enum instead of using char literals.
Admin
They aren't uppercase, they are randomcase like the other names. Visual Basic 6 fixes the case for you and does a shitty job. Experienced VB6 programmers have case insensitive eyes.
Admin
I fail to see the use of this. Do they want to write something like
Status = s
in stead of
Status = Shipped
because that is so much clearer.
Admin
Trivia time! In Java at least, an
enum
is a class. In one of my projects, I've got anenum
that implementsPredicate
to provide a JSON-friendly representation of the always-true and always-false predicates. The standard library actually uses this to give you aSet
implementation backed by a bitfield (okay, backed by a bitfield if the enum has 64 or fewer elements, anyway)....well I think it's neat, anyway!
Admin
Is it wrapping/screen-scraping some old greenscreen type system no-one wants to modify and those end up as sendkeys? Still a WTF, but at least one with some sort of point to it.
Admin
VB6 is case preserve. With a Dim wHaTtheHEck it will keep that case from the highest declared variable even if you try to do a new Dim (local variable?) elsewhere Case sensitivity in computer languages is at the same level as NULL. Case preservation it should be!
Admin
I like that in Java you can define member variables inside your enum and then have each enum option assign values to them.
So you still have normal ordinal enums, can iterate over all of them easily, but still can convert them to a char or string for storing into database ('u' is a lot more readable in a database dump than 4) or back.
Admin
So if you have a global variable "GotHere", you cannot have an unrelated local variable called "GoThere"? Yeah, that's totally not a WTF!
Admin
That's WTF too. Perfectly confusing.
Admin
That's because you've never worked in a loosely-typed language (VB.Net springs to mind) where the call site "knows" that the enum is actually a random collection of English-specific characters and makes use of that "knowledge" by switching on ASCII characters, because "it's all the same thing, innit?"
No.
No, it int.
And I have the scars to prove it.
Admin
Many bugs are caused by to little lexical distance between variable names. Your's a perfect example.
Admin
Was meant as reply to Foo AKA Fooo
Admin
Many examples of misunderstanding are caused by bad grammar. Yours is a perfect example!
(Sorry about this, I just had to say it)
Admin
:-) Probably correct, but for a non native English speaker not too bad ...
Admin
Nope. "GoHere" is closer to "GotHere" than "GoThere" is, yet it works fine. If you want warnings on close name matches, implement that instead of relying on case-insensitivity catching just a few random cases.
Admin
Consistent capitalization helps readability, and case sensitivity is an easy way to enforce it.
Admin
This isn't a WTF - it's pretty smart. You have a set of existing status codes (E, S, U, etc). Each one means something. Additionally, you need to convert to and from the meaning frequently, and you cannot screw up that conversion because things will break badly. How do you make sure that in your CODE, you can use the MEANING, but in your real-world-printed-STATUS, you never mistranslate? You could do a custom function to make sure that you don't get it wrong, but then some gimp will probably forget to use it. OR you could make sure that it maps EXACTLY to the correct character, thus ensuring that the meaning and the real-world-character are always 100% synchronized - and ALSO ensuring that no programmer is able to add in another "meaning" constant without being aware of whether they're overloading an existing status code. This isn't a WTF, it's actually brilliant.
(Yes, you could do it in another way, yes, this is "abuse" of enums, blah blah blah. There can be a fine line between "abuse" and "elegant use of existing functionality" - see Duff's Device, for example, or MANY of the hacks used in game programming. How 'bout you take your enterprise coding standards and shove them where the sun don't shine, eh?)
Admin
That would be non-native. "non" is not a word.