- 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
First!!!!!!!!!!!!!!!!
Damn you Aksimet.
Admin
Please stop making fun of Nagesh and his taxi
Admin
That is the most horrific thing I've seen all day and I sit next to Nagesh at HackSoft Hyderabad. I've seen things, awful things (like his comments on the TDWTF).
Admin
TRWTF is the capital O.
Admin
Those constant are for making code more readable. In VBScript there is no type. So everything needs to have some silly hunger notation. Type based language > Non Type based language.
Developer could have used this small hack in place of defining constants.
Admin
Admin
Good programming languages have enums as primitive types. This is a major flaw in all of C, C++ and Java. A big part of the advantage here is to have a guaranteed closed set, so that (a) you can't get a value outside of the set (including the IA vulnerabilities); (b) if you do need to add a value, then the compiler should be able to tell you (if you've coded it well) what code needs to be updated to handle the new value.
Admin
That's a situation that theoretically might be perfectly suited to an enum. But they decided to use a series of badly named constants.
Admin
If yuo truly in Hyderabad, tell me quick, where is best place to get Biryani. ALso tell me what is colour of Auto in Hyderabad?
Admin
If yuo truly in Hyderabad, tell me quick, where is best place to get Biryani. ALso tell me what is colour of Auto in Hyderabad?
Admin
What's the old saying... "give a man a hammer, and everything starts to look like a nail"?
I guess there's some creativity here, but it's negative creativity -- which, of course, powers TDWTF as much as fake South Asian commenters...
Admin
What's worse is that only H has the correct value.
Admin
Clearly he should have used an enum of strings instead of chars. See how it improves readability:
See? Much better. And unlike the char solution, he won't need to change his code whenever ASCII changes.Admin
It's upper case, not capital. As is the 'H', for equally baffling reasons.
Admin
Admin
"That which has been seen, cannot be unseen".
BTW, all of the Ascii values used here are for the upper-case letters, not the lower case ones. This adds an extra layer of wrong frosting onto the entire cake of wrongness.
Admin
So enlighten me: what's the difference between upper case (or uppercase as it is preferred) and capital?
Admin
I would not have defined constants here. But we got a lot of enums here that are stored in the database in char fields. This allows legacy programs to keep their record layouts while we migrate to modern languages.
Admin
A work of art (pseduo)codeblock would be more like this:
Admin
..."upper case" and "capital" mean exactly the same thing in everyday English.
Admin
Actually, Java has had proper enums for over 6 years now... and they're very powerful, more so than in pretty much every other language. A Java enum isn't just syntactic sugar for an int with a compiler-checked range of values. It's a fully-fledged class with fields and methods (the latter of which can even be overriden for individual instances).
Admin
Eipux o' both your houses!
Admin
Admin
Well done Nagesh, that's the funniest damn thing I've read all week.
Keep on trolling!
Admin
Not sure about other languages, but in .Net, if you have a enum like this:
It would still work perfectly fine to say this:
Which is why if you've got a switch statement on that enum, it's good to have a default case throw an arg out or range exception...
PS: what is IA vulnerability?
Admin
one book i read some time back had this hunger notation. it was named for some guy named charlie who used to work with microsoft!
Admin
HumanType.Woman.getEggsAndMakeMeADamnOmelet();
Admin
ewww, really? I wouldn't call that "powerful"... I think code smell is more like it.
Admin
And most often, the things we call capital letters are actually just upper case letters that look like capital letters, but are different because they are not on the capitals of buildings...
Admin
Admin
You can also do this:
enum Test { a = 'a', b = 'b' };
Admin
Admin
Admin
This is actually pretty sweet. It lets you use characters in an enum, while at the same time preventing single-letter variables!
The only WTF is that they can still use single-letter local variables, because they've used const instead of #define, but I'm sure they're not using local variables anyway.
Admin
Admin
QFT. Java's "powerful" enums are just plain scary.
Admin
So what? Someone was too lazy to type a couple of single quotes, which is, of course, the only thing wrong with this...
Admin
This is so full of win, it hurts.
Admin
Quick find the Upps Lock key on your keyboard.
Admin
@brazzy: Good point!
@C-Octothrope: Making silly comment online is not going to take away java powerfulness from it.
Admin
So tell me, what other fields and methods would you add to Int32? Maybe int.ToXml()?, or int.TheRealREALValueShhDontTellAnyone?
Admin
Nagesh my Indian imitator, you just made my day...
Admin
Addendum (2011-04-14 11:23): So people are still getting confused by what I mean here. My poor choice of wording I guess. Let me clarify for any newcomers:
Not knowing how to utilize features for which you never have a business need or design need does not make you a bad programmer.
Admin
My favorite one is the Pallet enum that has only two possible states.
Admin
Ah, art classes. I guess, that explains your code then.
Admin
When I worked in a letterpress typesetting printing company, for reasons that escape me, 'k' was actually found in the upper case, not the lower case.
(where case = large tray about 3 foot wide which had lead type in it. See here: alembicpress.co.uk/Typecases/Index.htm)
Admin
Um, hello? Pray tell at what point does this absurd argument end?
Oh, I don't know how to use abstract classes, but that's OK. No need for them. I'm still an otherworldly java dev.
Admin
Sorry I don't get your joke!
Admin
I think there may still be a useful distinction between "Capital" and "Uppercase".
When I learned to write, cursively and now over sixty years ago, what we learned to write included the capital letters, some of which looked quite unlike their small letters.
When I learned to type, now over fifty years ago, typewriters had uppercase characters. Which, common lore has it, came from printers storing these letters in their upper case and the more used small letters in their more easily reached lower case.
Agreed, there's no practical distinction today for most of us, but they got here by separate routes.
I am again reminded of the old joke, from back in the exchange days, where someone orally gives their phone number, CApital 2-3456, the person starting to write it hesitates, and finally asks: Uh, how do you make a capital 2?
captcha: conventio - an Italian nunnery
Admin
And to that I answer that while Int32 is used as-is (not sure if .Net lets you extend it, but I imagine there would be little demand because integers are a rather complete concept), enums inherently require you to define your own, and they often represent distinct domain concepts with meanings far beyond "there are only these specific instances of this thing".
So why should they in an OO language not be implemented as objects that can hold additional data and even functionality?