• C-Octothorpe (unregistered) in reply to Nagesh
    Nagesh:
    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!

    There was no joke, which is what makes it funny. :)

  • River Tam (unregistered) in reply to thosrtanner
    typedef enum
    {
       true,
       false,
       file_not_found
    } bool;
    

    Also, I can kill you with my brain.

  • (cs) in reply to Power Troll
    Power Troll:
    boog:
    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?

    Well, considering I was talking about one context and not generally speaking, it ends as soon as you try to apply it elsewhere. Oh look, here you go:

    Power Troll:
    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.
    WhoTF said anything about "not knowing how to use" anything? I was talking about not knowing how to put something to use that you don't need. Exactly which comment were you reading?
  • Obnoxious Frog (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.

    Examples of languages which handle this perfectly: OCaml and Haskell. There enumerations are just a trivial case of algebraic data types.

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

    You don't like extension methods? How about an int.ToIntPtr()?

  • itsmo (unregistered) in reply to hoodaticus
    hoodaticus:
    My favorite one is the Pallet enum that has only two possible states.

    Yes - he forgot 'File not found'

  • (cs) in reply to boog
    boog:
    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?
    Hmmm... Yes, I think that's exactly what I'm saying. Because nobody really *needs* anything other than a couple of switches to enter machine code one bit at a time. Good programmers can recognize a useful new feature even though they have done without it so far.
  • (cs) in reply to boog
    boog:
    Power Troll:
    boog:
    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?

    Well, considering I was talking about one context and not generally speaking, it ends as soon as you try to apply it elsewhere. Oh look, here you go:

    Power Troll:
    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.
    WhoTF said anything about "not knowing how to use" anything? I was talking about not knowing how to put something to use that you don't need. Exactly which comment were you reading?

    boog, at what point does "not putting something to use that you don't need" become laughably absurd to you in Java? Abstract classes? Static methods? Methods period?

    Your premise, that someone who fails to understand how to "put something to use" that s/he does not understand is not necessarily a bad programmer, is completely nonsensical. By that logic I could be a decent OO programmer producing a program with one class with 20 static methods simply because it is not "useful" to me to understand any of the following concepts:

    Class instantiation Member variables Non-static methods

    etc.

    Do you see why what you're saying is ridiculous?

  • (cs) in reply to brazzy
    brazzy:
    boog:
    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?
    Hmmm... Yes, I think that's exactly what I'm saying. Because nobody really *needs* anything other than a couple of switches to enter machine code one bit at a time. Good programmers can recognize a useful new feature even though they have done without it so far.
    Point: missed.

    By need, I don't mean the literal sense you've suggested. And what's useful/powerful to one person might be overly-complex/burdensome-to-maintain to another. That doesn't make either person a bad programmer.

  • (cs) in reply to Power Troll
    Power Troll:
    boog, at what point does "not putting something to use that you don't need" become laughably absurd to you in Java? Abstract classes? Static methods? Methods period?
    Wow, your name doesn't fail you. I believe I just said I wasn't speaking generally. Thanks for not reading!
    Power Troll:
    Your premise, that someone who fails to understand how to "put something to use" that s/he does not understand is not necessarily a bad programmer, is completely nonsensical.
    Handsome straw man you got there. Not my premise though. I wasn't talking about anyone's level of understanding. Try again.
    Power Troll:
    By that logic blah blah bull-shit blah... Do you see why what you're saying is ridiculous?
    Why yes, when you take my comment out of context and reconstruct it into twisted words that don't even mean the same thing anymore, it does sound quite ridiculous. I guess I learned my lesson.
  • Abso (unregistered) in reply to lesle
    lesle:
    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

    Ok, so the words "capital" and "uppercase" were once used in separate contexts, but they still both meant "the form of a letter used to begin sentences and proper names, to write/print acronyms, and sometimes to write/print whole words that are emphasized."

    Perhaps there are contexts where the distinction matters, but I'm hard pressed to think of them. I certainly don't see how it matters when discussing text stored in a computer. Well, unless you are using an encoding which represents uppercase and capital letters differently, but I doubt such an encoding exists.

  • Bit Head (unregistered) in reply to Steve The Cynic
    Steve The Cynic:
    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...

    If you are sitting at a US English keyboard right now, look down at the key just above the left Shift key. It probably is labeled "Caps Lock". Whaddaya suppose the "Caps" in that phrase stands for?

  • (cs) in reply to boog
    boog:
    Wow, your name doesn't fail you. I believe I just said I wasn't speaking generally. Thanks for not reading!
    So you asked a rhetorical question about programming skill yet weren't speaking generally?

    haha, alright man.

  • Also Not Gary (unregistered) in reply to iToad
    iToad:
    "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.

    mmmmm..... frosting
  • C-Octothorpe (unregistered) in reply to Power Troll
    Power Troll:
    boog:
    Power Troll:
    boog:
    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?

    Well, considering I was talking about one context and not generally speaking, it ends as soon as you try to apply it elsewhere. Oh look, here you go:

    Power Troll:
    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.
    WhoTF said anything about "not knowing how to use" anything? I was talking about not knowing how to put something to use that you don't need. Exactly which comment were you reading?

    boog, at what point does "not putting something to use that you don't need" become laughably absurd to you in Java? Abstract classes? Static methods? Methods period?

    Your premise, that someone who fails to understand how to "put something to use" that s/he does not understand is not necessarily a bad programmer, is completely nonsensical. By that logic I could be a decent OO programmer producing a program with one class with 20 static methods simply because it is not "useful" to me to understand any of the following concepts:

    Class instantiation Member variables Non-static methods

    etc.

    Do you see why what you're saying is ridiculous?

    Wow, reading comprehension fail!

    The fact that I don't use every nook and cranny of my development platform doesn't make me a bad programmer. In fact, it makes me an efficient programmer. I'm going to use the correct tools for the correct situations.

    Does the problem call for an instance of an object? No? Ok then, I can create a static class with static methods. I can even add some caching and thread safety to make it hella fast...

    Do I need object inheritance? Yes? Abstract, and away we go!

    Do I need loose coupling? Yes? Here we are, interfaces...

    Your argument is nonsensical and completely off the mark, but you keep supplying and proving your own arguments... It makes you more right, right?

  • (cs) in reply to Power Troll
    Power Troll:
    boog:
    Wow, your name doesn't fail you. I believe I just said I wasn't speaking generally. Thanks for not reading!
    So you asked a rhetorical question about programming skill yet weren't speaking generally?
    WhenTF did I ask a rhetorical question about programming skill? Do you only speak in Strawman?

    I said the guys ripping on all the whizbang-bells-and-whistles that come with Java's Enum are entitled to their opinions, and that not having any business or design need for Java's Enum themselves does not make them bad programmers. What about this has to do with programming skill?

  • philly guy (unregistered) in reply to Someone who can't be bothered to login from work
    Someone who can't be bothered to login from work:
    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.

    Yes, just yesterday I mailed my tax return to Harrisburg, the upper case of Pennsylvania.

  • English Dick (unregistered) in reply to philly guy
    philly guy:
    Someone who can't be bothered to login from work:
    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.

    Yes, just yesterday I mailed my tax return to Harrisburg, the upper case of Pennsylvania.

    I tried to open a business there but couldn't get enough venture upper case raised.

  • (cs) in reply to C-Octothorpe
    C-Octothorpe:

    Wow, reading comprehension fail!

    The fact that I don't use every nook and cranny of my development platform doesn't make me a bad programmer. In fact, it makes me an efficient programmer. I'm going to use the correct tools for the correct situations.

    Does the problem call for an instance of an object? No? Ok then, I can create a static class with static methods. I can even add some caching and thread safety to make it hella fast...

    Do I need object inheritance? Yes? Abstract, and away we go!

    Do I need loose coupling? Yes? Here we are, interfaces...

    Your argument is nonsensical and completely off the mark, but you keep supplying and proving your own arguments... It makes you more right, right?

    Um, yes. Except, as you explicitly stated, you have a clear understanding of when to use language-appropriate tools. That was not the context of the original statement, which you conveniently ignored.

    If we go to the context of the original post, the hypothetical developer in question is not convinced of the utility of a particular language tool. Perhaps he is justifiably skeptical of the benefits or uses that the tool brings, when weighed alongside any negatives, or perhaps not.

    boog then replied that one who does not see as tool as useful means that one has no use for the tool himself (or perhaps he meant something different, I'm not sure). He then asked, "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?"

    My stance is that yes, one can be an absolutely terrible programmer by not understanding how to make use of (==not understanding how to use? Apparently not) features that he "doesn't need". Nobody really needs to use objects, interfaces, abstract classes, polymorphism, threads, or methods besides main() to be a java developer. Indeed, a poor developer could very likely convince himself that these things aren't needed at all, and as a result, not understand how to make use of them.

    boog:
    WhenTF did I ask a rhetorical question about programming skill? Do you only speak in Strawman?

    I said the guys ripping on all the whizbang-bells-and-whistles that come with Java's Enum are entitled to their opinions, and that not having any business or design need for Java's Enum themselves does not make them bad programmers. What about this has to do with programming skill?

    Anyway, it's now obvious to me that I read way too much into boog's statement. My bad.

  • Gunslinger (unregistered)

    I'm sure there's some reasonable explanation for why 'H' and 'O' are capitalized...

  • C-Octothorpe (unregistered) in reply to hoodaticus
    hoodaticus:
    C-Octothorpe:
    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?

    You don't like extension methods? How about an int.ToIntPtr()?

    Ha, I was going to say "except extension methods in C#" (we think alike, it's scary)... I do like them, but not too crazy about them. They're just syntactic sugar, and aren't really supported by intellisense (try to type .ToIntPtr if you don't have the right using statement where the extension is defined), also because a while back a developer I very highly respect convinced me that it's not "pure", but that's neither here nor there...

    In any case, extension methods are different because it's not like you're subtyping Int32, right? And that's what bothers me because you're giving different meaning to something that is a single unit of something. It also breaks polymorphism (which obviously doesn't work for value types anyway) because if MyEnumType.First has a .ToFoo(), but MyEnumType.Second has a .ToBar(), then you're doing something wrong IMO (imagine the code necessary to handle that). Of course all of this is useless if my understanding of java enums is completely off base...

  • caper (unregistered) in reply to C-Octothorpe

    "Actually, Java has had proper enums for over 6 years"

    Ooooh, 6 years, fancy that.

    Yet I was using them in Pascal in the 1980s.

  • CoderHero (unregistered) 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?

    The ability to troll people I guess.

  • Jim Fell (unregistered)

    Although this would be difficult to implement using Windows, an enumeration of strings could conceptually be done in an embedded environment using a vector table.

    First, you'd need to define a location in memory for the vector table. Let's call it VTBL_ADDR.

    Next, define your enumeration:

    typedef enum STRING_ENUMS
    {
      STR0 = VTBL_ADDR,
      STR1 = VTBL_ADDR + 1,
      STR2 = VTBL_ADDR + 2,
      MAX_ENUMS
    };

    Setup the vector table at the predefined address. Different compilers may use pragma or linker settings. The vector table would look something like this:

    volatile const unsigned char * vStrTable[MAX_ENUMS] = {0};

    The strings need to be declared separately because we need to know where each is located in memory for this to work.

    volatile const unsigned char * VSTR0 = "String 0\0";
    volatile const unsigned char * VSTR1 = "String 1\0";
    volatile const unsigned char * VSTR2 = "String 2\0";

    Finally, the application's init code needs to wire the vector table to the strings:

    *((unsigned char **)VTBL_ADDR) = &VSTR0;
    *((unsigned char **)(VTBL_ADDR + 1)) = &VSTR1;
    *((unsigned char **)(VTBL_ADDR + 2)) = &VSTR2;
    

    Viola! You now have a string enumeration. Essentially, an enumeration of pointers boils down to an enumeration of integers. I did something similar to this for a project about a year ago, so I know it can be done. However, this code I wrote off the top of my head and is untested; it may (probably) needs some tweaking.

  • Jim Fell (unregistered) in reply to Jim Fell

    Okay, lol, MAX_ENUMS would need to be defined separately.

  • Gunslinger (unregistered) in reply to philly guy
    philly guy:
    Someone who can't be bothered to login from work:
    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.

    Yes, just yesterday I mailed my tax return to Harrisburg, the upper case of Pennsylvania.

    Context matters. Morons.

  • (cs) in reply to Power Troll
    Power Troll:
    Anyway, it's now obvious to me that I read way too much into boog's statement.
    You'll find I'm not known for making deep, thought-provoking comments. Just shallow, almost-irrelevant observations.
  • (cs) in reply to Gunslinger
    Gunslinger:
    philly guy:
    Someone who can't be bothered to login from work:
    ..."upper case" and "capital" mean exactly the same thing in everyday English.
    Yes, just yesterday I mailed my tax return to Harrisburg, the upper case of Pennsylvania.
    Context matters. Morons.
    So does your sense of humor. You just have to use it.
  • (cs) in reply to Paul Karlsson
    Paul Karlsson:
    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.

    That might make some sense if (1) it was commented as such and (2) you only ever have one legacy program per data field (or they all use the same values). Personally, I would create functions like TranslateFooToLegacyBar(), where Foo is the name of the data field and Bar is the name of the legacy program.

  • LARRY (unregistered) in reply to Bit Head
    Bit Head:
    If you are sitting at a US English keyboard right now, look down at the key just above the left Shift key. It probably is labeled "Caps Lock". Whaddaya suppose the "Caps" in that phrase stands for?
    IT IS REFERRING TO THE KEY-CAPS, THE LETTERS PRINTED ON YOUR KEYS. YOU HAVE TO LOCK THEM SO HACKERS DON'T TAKE THEM OR CHANGE THEM TO CHINESE OR SOMETHING. I ALWAYS HAVE MINE ON WHEN I GO ONLINE AND YOU SHOULD TOO, FOR SAFETY.

    besides if you live dangerously and unlock your caps you will notice that the letters in your post are not shaped anything like the drawings on your key caps. see? they hacked your font!

  • Anachronda (unregistered) in reply to Steve The Cynic
    Steve The Cynic:
    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).
    Only if "capitol" and "capital" were *also* the same thing.
  • Master and Commander of the Troll Amry (unregistered) in reply to boog
    boog:
    brazzy:
    boog:
    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?
    Hmmm... Yes, I think that's exactly what I'm saying. Because nobody really *needs* anything other than a couple of switches to enter machine code one bit at a time. Good programmers can recognize a useful new feature even though they have done without it so far.
    Point: missed.

    By need, I don't mean the literal sense you've suggested. And what's useful/powerful to one person might be overly-complex/burdensome-to-maintain to another. That doesn't make either person a bad programmer.

    YHBT. YHL. HAND.

    Good job, boog.

  • (cs) in reply to boog
    boog:
    Power Troll:
    boog:
    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?

    Well, considering I was talking about one context and not generally speaking, it ends as soon as you try to apply it elsewhere. Oh look, here you go:

    Power Troll:
    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.
    WhoTF said anything about "not knowing how to use" anything? I was talking about not knowing how to put something to use that you don't need. Exactly which comment were you reading?

    A very good point. Only people who have real programming jobs getting computers to do something interesting and/or important get to discover the delightful convenience and elegance of a fully-fledged enum implementation. If, as you say, your job doesn't put that level of intellectual demands upon you, you can happily get away without bothering to get to grips with enums at all.

  • (cs) in reply to Bit Head
    Bit Head:
    Steve The Cynic:
    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...

    If you are sitting at a US English keyboard right now, look down at the key just above the left Shift key. It probably is labeled "Caps Lock". Whaddaya suppose the "Caps" in that phrase stands for?

    Um ... Dutch caps? So caps lock is a bit like a chastity belt, yeah?

  • C-Octothorpe (unregistered) in reply to Matt Westwood
    Matt Westwood:
    boog:
    Power Troll:
    boog:
    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?

    Well, considering I was talking about one context and not generally speaking, it ends as soon as you try to apply it elsewhere. Oh look, here you go:

    Power Troll:
    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.
    WhoTF said anything about "not knowing how to use" anything? I was talking about not knowing how to put something to use that you don't need. Exactly which comment were you reading?

    A very good point. Only people who have real programming jobs getting computers to do something interesting and/or important get to discover the delightful convenience and elegance of a fully-fledged enum implementation. If, as you say, your job doesn't put that level of intellectual demands upon you, you can happily get away without bothering to get to grips with enums at all.

    ... or, to it's absurd yet logical conclusion, software development as a whole too...

  • (cs) in reply to Jim Fell
    Jim Fell:
    Although this would be difficult to implement using Windows, an enumeration of strings could conceptually be done in an embedded environment using a vector table.

    First, you'd need to define a location in memory for the vector table. Let's call it VTBL_ADDR.

    Next, define your enumeration:

    typedef enum STRING_ENUMS
    {
      STR0 = VTBL_ADDR,
      STR1 = VTBL_ADDR + 1,
      STR2 = VTBL_ADDR + 2,
      MAX_ENUMS
    };

    Setup the vector table at the predefined address. Different compilers may use pragma or linker settings. The vector table would look something like this:

    volatile const unsigned char * vStrTable[MAX_ENUMS] = {0};

    The strings need to be declared separately because we need to know where each is located in memory for this to work.

    volatile const unsigned char * VSTR0 = "String 0\0";
    volatile const unsigned char * VSTR1 = "String 1\0";
    volatile const unsigned char * VSTR2 = "String 2\0";

    Finally, the application's init code needs to wire the vector table to the strings:

    *((unsigned char **)VTBL_ADDR) = &VSTR0;
    *((unsigned char **)(VTBL_ADDR + 1)) = &VSTR1;
    *((unsigned char **)(VTBL_ADDR + 2)) = &VSTR2;
    

    Viola! You now have a string enumeration. Essentially, an enumeration of pointers boils down to an enumeration of integers. I did something similar to this for a project about a year ago, so I know it can be done. However, this code I wrote off the top of my head and is untested; it may (probably) needs some tweaking.

    "Viola". OFFS, someone else on the big fiddle.

  • Peter (unregistered) in reply to Anachronda
    Anachronda:
    Steve The Cynic:
    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).
    Only if "capitol" and "capital" were *also* the same thing.
    Where do you need the word "capitol" in Steve's sentence?
  • (cs) in reply to LARRY
    LARRY:
    Bit Head:
    If you are sitting at a US English keyboard right now, look down at the key just above the left Shift key. It probably is labeled "Caps Lock". Whaddaya suppose the "Caps" in that phrase stands for?
    IT IS REFERRING TO THE KEY-CAPS, THE LETTERS PRINTED ON YOUR KEYS. YOU HAVE TO LOCK THEM SO HACKERS DON'T TAKE THEM OR CHANGE THEM TO CHINESE OR SOMETHING. I ALWAYS HAVE MINE ON WHEN I GO ONLINE AND YOU SHOULD TOO, FOR SAFETY.

    besides if you live dangerously and unlock your caps you will notice that the letters in your post are not shaped anything like the drawings on your key caps. see? they hacked your font!

    +5001 FUCKING BIG WIN.

  • airdrik (unregistered) in reply to C-Octothorpe
    C-Octothorpe:
    In any case, extension methods are different because it's not like you're subtyping Int32, right? And that's what bothers me because you're giving different meaning to something that is a single unit of something. It also breaks polymorphism (which obviously doesn't work for value types anyway) because if MyEnumType.First has a .ToFoo(), but MyEnumType.Second has a .ToBar(), then you're doing something wrong IMO (imagine the code necessary to handle that). Of course all of this is useless if my understanding of java enums is completely off base...
    But that's not how they work. MyEnumType (being the class of the enum) would have a set of properties and methods which are shared by its values (MyEnumType.First and MyEnumType.Second). The definition would look something like this:
    public enum MyEnumType
    {
        First('Foo'),
        Second('Bar');
        public String value;
        public MyEnumType(String value)
        {
            this.value = value;
        }
    }
    

    The enum type also comes with a few other handy features like a name method which returns the enum's name as a string (we actually store enum names in the database rather than worrying about having and syncing a separate enum names table), being iterable (iterate over the values of the enum).

    Of course the bottom line in deciding if it's worth having all of this extra functionality is the question: what do I want/need to do with this enum? Is there some functionality that would be worth putting on the enum itself?

    One example I can think of is with statuses where some statuses are errors (application died, database error, application error, data error), some are success (success with new data, success but no data). You could mark in the enum which values are errors and which are success. Then you don't have to have a separate function which remembers which ones are which because it is right there on the enum value.

  • Ken B. (unregistered) in reply to English Dick
    English Dick:
    philly guy:
    Someone who can't be bothered to login from work:
    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.
    Yes, just yesterday I mailed my tax return to Harrisburg, the upper case of Pennsylvania.
    I tried to open a business there but couldn't get enough venture upper case raised.
    Jokes like these should be an upper case offense.
  • Ken B. (unregistered) in reply to Gunslinger
    Gunslinger:
    I'm sure there's some reasonable explanation for why 'H' and 'O' are capitalized...
    There was a need for an enum for water.
  • anonymouser (unregistered) in reply to Gunslinger
    Gunslinger:
    I'm sure there's some reasonable explanation for why 'H' and 'O' are capitalized...
    The man was a model train enthusiast?
  • justsomedude (unregistered) in reply to English Dick
    English Dick:
    philly guy:
    Someone who can't be bothered to login from work:
    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.

    Yes, just yesterday I mailed my tax return to Harrisburg, the upper case of Pennsylvania.

    I tried to open a business there but couldn't get enough venture upper case raised.

    I think the last two posters don't understand the difference between capital and capitol.

    CAPTCHA: eros - as in, those posters commited an eros.

  • English Dick (unregistered) in reply to airdrik
    airdrik:
    One example I can think of is with statuses where some statuses are errors (application died, database error, application error, data error), some are success (success with new data, success but no data). You could mark in the enum which values are errors and which are success. Then you don't have to have a separate function which remembers which ones are which because it is right there on the enum value.

    Code needs to be refactored if that's your best example. An enum in this case should only indicate SUCCESS or FAILURE and whatever object that holds the contents of that enum should describe the type (ApplicationResponse, DatabaseResponse, SoapResponse, EnterpriseyResponse)

  • Ken B. (unregistered) in reply to Anachronda
    Anachronda:
    Steve The Cynic:
    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).
    Only if "capitol" and "capital" were *also* the same thing.
    Fortunately, they don't mean the same thing, which is why "capitol" is not needed in "Steve The Cynic"'s post.

    Note that I have toured the Capitol while visiting the Capital.

  • Ken B. (unregistered) in reply to justsomedude
    justsomedude:
    English Dick:
    philly guy:
    Someone who can't be bothered to login from work:
    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.
    Yes, just yesterday I mailed my tax return to Harrisburg, the upper case of Pennsylvania.
    I tried to open a business there but couldn't get enough venture upper case raised.
    I think the last two posters don't understand the difference between capital and capitol.
    Or perhaps it is you who fails to understand the difference?

    None of the previous posts mentioned need "capitol".

  • User of Dictionaries (unregistered) in reply to justsomedude
    justsomedude:
    English Dick:
    philly guy:
    Someone who can't be bothered to login from work:
    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.

    Yes, just yesterday I mailed my tax return to Harrisburg, the upper case of Pennsylvania.

    I tried to open a business there but couldn't get enough venture upper case raised.

    I think the last two posters don't understand the difference between capital and capitol.

    CAPTCHA: eros - as in, those posters commited an eros.

    Sorry 'dude, but capitol is used solely to refer to "the building in which a legislative assembly meets".

  • Abso (unregistered) in reply to User of Dictionaries
    User of Dictionaries:
    Sorry 'dude, but capitol is used solely to refer to "the building in which a American legislative assembly meets".
    FTFY.
  • C-Octothorpe (unregistered) in reply to airdrik
    airdrik:
    C-Octothorpe:
    In any case, extension methods are different because it's not like you're subtyping Int32, right? And that's what bothers me because you're giving different meaning to something that is a single unit of something. It also breaks polymorphism (which obviously doesn't work for value types anyway) because if MyEnumType.First has a .ToFoo(), but MyEnumType.Second has a .ToBar(), then you're doing something wrong IMO (imagine the code necessary to handle that). Of course all of this is useless if my understanding of java enums is completely off base...
    But that's not how they work. MyEnumType (being the class of the enum) would have a set of properties and methods which are shared by its values (MyEnumType.First and MyEnumType.Second). The definition would look something like this:
    public enum MyEnumType
    {
        First('Foo'),
        Second('Bar');
        public String value;
        public MyEnumType(String value)
        {
            this.value = value;
        }
    }
    

    The enum type also comes with a few other handy features like a name method which returns the enum's name as a string (we actually store enum names in the database rather than worrying about having and syncing a separate enum names table), being iterable (iterate over the values of the enum).

    Of course the bottom line in deciding if it's worth having all of this extra functionality is the question: what do I want/need to do with this enum? Is there some functionality that would be worth putting on the enum itself?

    One example I can think of is with statuses where some statuses are errors (application died, database error, application error, data error), some are success (success with new data, success but no data). You could mark in the enum which values are errors and which are success. Then you don't have to have a separate function which remembers which ones are which because it is right there on the enum value.

    Thanks for explaining that more clearly, but I have got to ask, what is the difference between an enum and a class other than the type modifier (class vs enum)?

  • (cs)

    and here I was thinking "Capitol" is some building in America.

Leave a comment on “A Char'd Enum”

Log In or post as a guest

Replying to comment #:

« Return to Article