• (cs)

    First!!!!!!!!!!!!!!!!

    Damn you Aksimet.

  • Char'd Enum (unregistered)

    Please stop making fun of Nagesh and his taxi

  • Nastesh (unregistered)

    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).

  • justsomedude (unregistered)

    TRWTF is the capital O.

  • (cs)

    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.

    'UNtested code. I don't do this for living.
    'I write work of art classes in java.
    Dim a
    a = "a"
    Wscript.Echo Asc(a)
    
  • TRWTF is VB (unregistered)
    Public Enum Comment
      What = w
      The = t
      Fsck = f
    End Enum
    
  • David Emery (unregistered)

    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.

  • (cs)

    That's a situation that theoretically might be perfectly suited to an enum. But they decided to use a series of badly named constants.

  • (cs) in reply to Nastesh
    Nastesh:
    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).

    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?

  • (cs) in reply to Nastesh
    Nastesh:
    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).

    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?

  • Rob (unregistered)

    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...

  • engunneer (unregistered)

    What's worse is that only H has the correct value.

  • (cs)

    Clearly he should have used an enum of strings instead of chars. See how it improves readability:

    '******* Status Constants ********
    Private Const MsgErrorStatus = 69
    Private Const MsgInformationStatus = 73
    Private Const ProdMsgStatus = 80
    Private Const UpLoadStatus = 85
    Private Const RemovedStatus = 88
    ...
    

    '******* Status Enums ********* Public Enum MessageStatus MsgError = MsgErrorStatus MsgInformation = MsgInformationStatus ProdMsg = ProdMsgStatus UpLoad = UpLoadStatus Removed = RemovedStatus End Enum ...

    See? Much better. And unlike the char solution, he won't need to change his code whenever ASCII changes.

  • dadasd (unregistered) in reply to justsomedude
    justsomedude:
    TRWTF is the capital O.

    It's upper case, not capital. As is the 'H', for equally baffling reasons.

  • (cs) in reply to dadasd
    dadasd:
    It's upper case, not capital. As is the 'H', for equally baffling reasons.
    You think? It's baffling to me that the rest are lower-case. Lower-case ASCII starts at 97, not 65.
  • iToad (unregistered)

    "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.

  • QJ (unregistered) in reply to dadasd
    dadasd:
    justsomedude:
    TRWTF is the capital O.

    It's upper case, not capital. As is the 'H', for equally baffling reasons.

    So enlighten me: what's the difference between upper case (or uppercase as it is preferred) and capital?

  • Paul Karlsson (unregistered)

    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.

  • (cs) in reply to Nagesh
    Nagesh:
    this small hack in place of defining constants.
    'UNtested code. I don't do this for living.
    'I write work of art classes in java.
    

    A work of art (pseduo)codeblock would be more like this:

    Pipe rene = new PipePicture();
    Debug.Assert(Not rene.GetType().Equals(Pipe));
    
  • Someone who can't be bothered to login from work (unregistered) in reply to dadasd
    dadasd:
    justsomedude:
    TRWTF is the capital O.

    It's upper case, not capital. As is the 'H', for equally baffling reasons.

    ..."upper case" and "capital" mean exactly the same thing in everyday English.

  • (cs) in reply to David Emery
    David Emery:
    Good programming languages have enums as primitive types. This is a major flaw in all of C, C++ and Java.

    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).

  • Jeremy (unregistered)

    Eipux o' both your houses!

  • drusi (unregistered) in reply to Nagesh
    Nagesh:
    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.

    'UNtested code. I don't do this for living.
    'I write work of art classes in java.
    Dim a
    a = "a"
    Wscript.Echo Asc(a)
    
    I thought hunger notation was when you named all your variables after foods.
  • (cs) in reply to Nagesh
    Nagesh:
    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.

    'UNtested code. I don't do this for living.
    'I write work of art classes in java.
    Dim a
    a = "a"
    Wscript.Echo Asc(a)
    

    Well done Nagesh, that's the funniest damn thing I've read all week.

    Keep on trolling!

  • C-Octothorpe (unregistered) in reply to David Emery
    David Emery:
    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.

    Not sure about other languages, but in .Net, if you have a enum like this:

    enum TestType
    {
      None = 0,
      Type1,
      Type2,
    }
    

    It would still work perfectly fine to say this:

    var t = (TestType)56;
    

    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?

  • (cs) in reply to drusi
    drusi:
    Nagesh:
    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.

    'UNtested code. I don't do this for living.
    'I write work of art classes in java.
    Dim a
    a = "a"
    Wscript.Echo Asc(a)
    
    I thought hunger notation was when you named all your variables after foods.

    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!

  • Vaca Loca (unregistered) in reply to brazzy
    brazzy:
    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).

    HumanType.Woman.getEggsAndMakeMeADamnOmelet();

  • C-Octothorpe (unregistered) in reply to brazzy
    brazzy:
    David Emery:
    Good programming languages have enums as primitive types. This is a major flaw in all of C, C++ and Java.

    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).

    ewww, really? I wouldn't call that "powerful"... I think code smell is more like it.

  • (cs) in reply to Someone who can't be bothered to login from work
    Someone who can't be bothered to login from work:
    ..."upper case" and "capital" mean exactly the same thing in everyday English.
    Only when talking about letters. Otherwise you would be able to go to your upper case city to see the new upper case ship being launched (well, you could if your capital city has shipyards capable of building capital ships).

    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...

  • (cs) in reply to C-Octothorpe
    C-Octothorpe:
    brazzy:
    David Emery:
    Good programming languages have enums as primitive types. This is a major flaw in all of C, C++ and Java.

    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).

    ewww, really? I wouldn't call that "powerful"... I think code smell is more like it.

    Right. "Powerful". As in, "holy frell, that is one powerful odor."

  • Anon (unregistered) in reply to C-Octothorpe

    You can also do this:

    enum Test { a = 'a', b = 'b' };

  • Nastesh (unregistered) in reply to Nagesh
    Nagesh:
    Nastesh:
    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).

    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?

    Well, Paradise is pretty popular but not the best in my opinion, Garden does a fine biryani, Bawarchi is alright but Hyderabad House gets my vote for top biryani. By "auto" do you mean the rickshaws? They're all yellow.

  • Stack Trace (unregistered) in reply to Vaca Loca
    java.lang.DoghouseException: If you don't know what you did wrong, I'm not going to tell you
            at com.thedailywtf.Sexist.getBreakfast(Sexist.java:1938)
            at com.thedailywtf.Read.readPost(Read.java:2073)
            at com.thedailywtf.Internet.wasteTime(Internet.java:1939)
            at com.thedailywtf.Processor$ProcessorThread.run(Processor.java:1056)
  • (cs)

    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.

  • (cs) in reply to neminem
    neminem:
    C-Octothorpe:
    brazzy:
    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).

    ewww, really? I wouldn't call that "powerful"... I think code smell is more like it.

    Right. "Powerful". As in, "holy frell, that is one powerful odor."
    Sour grapes much? If you can't understand the usefulness through the description, no language in the world is going to make you a good programmer.

  • (cs) in reply to David Emery
    David Emery:
    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.

    QFT. Java's "powerful" enums are just plain scary.

  • (cs)

    So what? Someone was too lazy to type a couple of single quotes, which is, of course, the only thing wrong with this...

  • C-Octothorpe (unregistered) in reply to Stack Trace
    Stack Trace:
    java.lang.DoghouseException: If you don't know what you did wrong, I'm not going to tell you
            at com.thedailywtf.Sexist.getBreakfast(Sexist.java:1938)
            at com.thedailywtf.Read.readPost(Read.java:2073)
            at com.thedailywtf.Internet.wasteTime(Internet.java:1939)
            at com.thedailywtf.Processor$ProcessorThread.run(Processor.java:1056)

    This is so full of win, it hurts.

  • Yojin (unregistered) in reply to Steve The Cynic

    Quick find the Upps Lock key on your keyboard.

  • (cs) in reply to brazzy
    brazzy:
    neminem:
    C-Octothorpe:
    brazzy:
    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).

    ewww, really? I wouldn't call that "powerful"... I think code smell is more like it.

    Right. "Powerful". As in, "holy frell, that is one powerful odor."
    Sour grapes much? If you can't understand the usefulness through the description, no language in the world is going to make you a good programmer.

    @brazzy: Good point!

    @C-Octothrope: Making silly comment online is not going to take away java powerfulness from it.

  • C-Octothorpe (unregistered) in reply to brazzy
    brazzy:
    neminem:
    C-Octothorpe:
    brazzy:
    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).

    ewww, really? I wouldn't call that "powerful"... I think code smell is more like it.

    Right. "Powerful". As in, "holy frell, that is one powerful odor."
    Sour grapes much? If you can't understand the usefulness through the description, no language in the world is going to make you a good programmer.

    So tell me, what other fields and methods would you add to Int32? Maybe int.ToXml()?, or int.TheRealREALValueShhDontTellAnyone?

  • C-Octothorpe (unregistered) in reply to Nagesh
    Nagesh:
    @brazzy: Good point!

    @C-Octothrope: Making silly comment online is not going to take away java powerfulness from it.

    Nagesh my Indian imitator, you just made my day...

  • (cs) in reply to brazzy
    brazzy:
    neminem:
    C-Octothorpe:
    brazzy:
    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).

    ewww, really? I wouldn't call that "powerful"... I think code smell is more like it.

    Right. "Powerful". As in, "holy frell, that is one powerful odor."
    Sour grapes much? If you can't understand the usefulness through the description, no language in the world is going to make you a good programmer.
    Bullshit. Not seeing the usefulness only amounts to not having any use for it himself, nothing more. Are you really suggesting he's not a good programmer because he doesn't know how to make use of features he doesn't need?

    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.

  • (cs)

    My favorite one is the Pallet enum that has only two possible states.

  • anonymouser (unregistered) in reply to Nagesh
    Nagesh:
    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.

    'UNtested code. I don't do this for living.
    'I write work of art classes in java.
    Dim a
    a = "a"
    Wscript.Echo Asc(a)
    

    Ah, art classes. I guess, that explains your code then.

  • (cs) in reply to QJ
    QJ:
    dadasd:
    justsomedude:
    TRWTF is the capital O.

    It's upper case, not capital. As is the 'H', for equally baffling reasons.

    So enlighten me: what's the difference between upper case (or uppercase as it is preferred) and capital?

    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)

  • (cs) in reply to boog
    boog:
    brazzy:
    neminem:
    C-Octothorpe:
    brazzy:
    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).

    ewww, really? I wouldn't call that "powerful"... I think code smell is more like it.

    Right. "Powerful". As in, "holy frell, that is one powerful odor."
    Sour grapes much? If you can't understand the usefulness through the description, no language in the world is going to make you a good programmer.
    Bullshit. Not seeing the usefulness only amounts to not having any use for it himself, nothing more. Are you really suggesting he's not a good programmer because he doesn't know how to make use of features he doesn't need?

    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.

  • (cs) in reply to anonymouser
    anonymouser:
    Nagesh:
    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.

    'UNtested code. I don't do this for living.
    'I write work of art classes in java.
    Dim a
    a = "a"
    Wscript.Echo Asc(a)
    

    Ah, art classes. I guess, that explains your code then.

    Sorry I don't get your joke!

  • lesle (unregistered)

    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

  • (cs) in reply to C-Octothorpe
    C-Octothorpe:
    So tell me, what other fields and methods would you add to Int32? Maybe int.ToXml()?, or int.TheRealREALValueShhDontTellAnyone?
    I'll read that as "enums are a simple concept, how could adding functionality to them possibly be anything except ridiculous overengineering?".

    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?

Leave a comment on “A Char'd Enum”

Log In or post as a guest

Replying to comment #:

« Return to Article