• (cs) in reply to itsmo
    itsmo:
    Zylon:
    Just for reference, how could be rewritten it in a single line:

    Yoda is writing for DailyWTF now?

    You mean:

    Writing for DailyWTF Yoda now is.

    Yoda uses "object, subject verb."

    So it would be "Writing for DailyWTF now, Yoda is."

  • Ken B. (unregistered) in reply to Zylon
    Zylon:
    Just for reference, how could be rewritten it in a single line:

    Yoda is writing for DailyWTF now?

    Beat me to it, Zylon did.

  • (cs)

    A Yodaspeak generator, has created someone, seems it.

    http://www.yodaspeak.co.uk/

  • F (unregistered) in reply to trtrwtf
    trtrwtf:
    ... (sorry, I don't have the jvm instruction set in my head)

    Hah! Call yourself a programmer?

  • (cs) in reply to Strike
    Strike:
    In 1.4 which I'm using there is no StringBuffer
    Um... StringBuffer was introduced in Java 1.0, and it's actually StringBuilder these days.

    And what kind of dysfunctional project has you using 1.4, which is three years past EOL.

  • (cs) in reply to OJ
    OJ:
    Also, I don't really get how anyone who has coded C for 20 years without realizing that it has enums has made it into manager position.

    C doesn't have enums. It has a hacky system for mapping constants onto integer values that it calls enums, but they're really just integers with a light dusting of semantic sugar.

  • (cs) in reply to grumpy
    grumpy:
    Half the time hate is caused by not understanding. The other half by understanding all too well. I wonder if there's a sweet spot between the two where one can actually be content with working in this business...? Never been in it but I live in hope.

    So what you are asking for is Just the right amount of ignorance?

  • (cs) in reply to F
    F:
    TheRider:
    ... a reason to read the fucking manual.

    You need a manual for that?

    No, I think he means open up the manual on the language and goto chapter 4 entitled "Enums and You".

  • Guy (unregistered)

    Please show some sensitivity. I once had an enum, and let me assure you: it was not laughing mater.

  • (cs) in reply to Severity One
    Severity One:
    Iceman:
    Just for reference, how could be rewritten it in a single line:

    public Integer checkStatus(Status status){ return status.ordinal(); }

    Of course, until someone calls the function with a null argument. Hello, NPE.
    But that shouldn't never not happen.
    FTFY

  • (cs) in reply to TheRider
    TheRider:
    In fact, most people don't understand Java Enums. But that is not a reason to not use them, it is rather a reason to read the fucking manual.

    Agred! 100%

    I was member in teem for many months, and I had to explane benefits of using enums to devlopers more experience than me. It was compleet waste of time as they laffed at me and went back to there ways of coding.

  • Architect (unregistered) in reply to Nagesh
    article:
    Just for reference, how could be rewritten it in a single line:
    public Integer checkStatus(Status status){
        return status.ordinal(); 
    }</div></BLOCKQUOTE>You see? In Java even a single line takes three lines!!
    
  • _ (unregistered) in reply to PedanticCurmudgeon
    PedanticCurmudgeon:
    Severity One:
    Iceman:
    Just for reference, how could be rewritten it in a single line:

    public Integer checkStatus(Status status){ return status.ordinal(); }

    Of course, until someone calls the function with a null argument. Hello, NPE.
    But that shouldn't never not unhappen.
    FTFY

  • (cs) in reply to Guy
    Guy:
    Please show some sensitivity. I once had an enum, and let me assure you: it was not laughing mater.

    This is geting old

  • Nagesh (unregistered) in reply to Nagesh
    Nagesh:
    TheRider:
    In fact, most people don't understand Java Enums. But that is not a reason to not use them, it is rather a reason to read the fucking manual.

    Agred! 100%

    I was member in teem for many months, and I had to explane benefits of using enums to devlopers more experience than me. It was compleet waste of time as they laffed at me and went back to there ways of coding.

    You are knowing what they say if everyone else looking like an idiot.

    Haker schoolboy.

  • (cs) in reply to Nagesh
    Nagesh:
    Guy:
    Please show some sensitivity. I once had an enum, and let me assure you: it was not laughing mater.

    This is geting old

    Agreed. Even Bob's not using this meme seriously any more.

  • Rob (unregistered) in reply to Nagesh
    Nagesh:
    Guy:
    Please show some sensitivity. I once had an enum, and let me assure you: it was not laughing mater.

    This is geting old

    I had a son who was geting old, but who cares?

  • big picture thinker (unregistered)

    TRWTF is: Why would you ever want/need to get the ordinal from the Enum?

    The whole point of the enum is to substitute constant words for a magic numbers. Once you create the enum, you should use it throughout the entire program. It is an integer already, or more precisely it resolves to an integer automatically. There's no reason to perform a function like that.

    If the lead developer has a C background then he should be aware of something essentially the same as an enum; which is of course a preprocessor macro. Once you #define X 1, you can simply use X in place of 1 for both assignment and evaluations. You never even need to know or care about what X is.

    CAPTCHA: transverbero

  • Impaler (unregistered) in reply to steenbergh
    steenbergh:
    OJ:
    Also, I don't really get how anyone who has coded C for 20 years without realizing that it has enums has made it into manager position.
    He'll probably do less damage when further removed from a keyboard.
    It is very common - that kind of programmers are often promoted to "more human tasks" and become managers, so that real programmers can do the job.
  • (cs) in reply to TheRider
    TheRider:
    In fact, most people don't understand Java Enums. But that is not a reason to not use them, it is rather a reason to read the fucking manual.

    Clearly, you have read the fucking manual.

  • (cs) in reply to frits
    frits:
    Jim Fell:
    This is a perfect example of why so many applications written in Java (and other high-level programming languages) are terribly inefficient. Most developers who have learned and written only in Java (or C#, etc.) don't have a basic understanding of what actually happens when their code is run. All programmers, regardless of the language they use, need to be aware of what the processor is doing when it executes an 'if' statement, or a 'switch', or when a function is called, etc.
    Actually, I love to not know. It almost always doesn't matter.
    This. As a lead dev or architect, would you really feel satisfied knowing that you're devs are wasting many hours\days\weeks evaluating CIL in order to micro-optimize a few lines of code, which in the end won't really make a lick of a difference?

    I think you overstepped when you said that every dev should know (in real-time as they're writing code) what each line will look like as byte-code, which is a massive waste of time, and as frits put it, very often won't matter anyway.

    I think what you should have said is that developers should know what happens beyond their IDE, which I can agree with, but to say that high-level languages are ineffecient is, well, wrong. High level languages are tools, and like any tool, can be misused.

  • nrc (unregistered) in reply to TheRider

    This is a serious question... This comes up again and again, in all sorts of languages. Besides calling these guys dummies, is there something about enums that is so hard to understand?

    Is there something specific coming from C? I learned Pascal first (has enums) then Java and then C and it made sense from day 1.

  • Ralph (unregistered) in reply to Jim Fell
    Jim Fell:
    All programmers, regardless of the language they use, need to be aware of what the processor is doing when it executes an 'if' statement, or a 'switch', or when a function is called, etc.
    I'm sorry, but that's a rather outdated attitude you're carrying around there, friend.

    Yes, long ago it was true you needed to understand a little something about the computer, but then we came up with these people called "users" who we encourage to know as little as possible, and even take pride in their ignorance, and we go all-out to make the software soooooooooo "easy to use" that even a drooling loonie can spastically click around and get something to happen. (Although if you know what you're doing, you'll find the emperor's new interface is actually harder to use.)

    And, now that our precious users are anointing themselves programmers too, we can't ask them to know anything there either.

  • (cs) in reply to Ralph
    Ralph:
    Jim Fell:
    All programmers, regardless of the language they use, need to be aware of what the processor is doing when it executes an 'if' statement, or a 'switch', or when a function is called, etc.
    I'm sorry, but that's a rather outdated attitude you're carrying around there, friend.

    Yes, long ago it was true you needed to understand a little something about the computer, but then we came up with these people called "users" who we encourage to know as little as possible, and even take pride in their ignorance, and we go all-out to make the software soooooooooo "easy to use" that even a drooling loonie can spastically click around and get something to happen. (Although if you know what you're doing, you'll find the emperor's new interface is actually harder to use.)

    And, now that our precious users are anointing themselves programmers too, we can't ask them to know anything there either.

    I am in agrement with you, partally. Sometime it is necesary to look under hood, sometime not required at all.

  • apoc9 (unregistered)

    In C++ enums are like named integers. However in Java they are full-fledged instances of class.

    Speaking of Java vs C++. I like this (http://jeetworks.org/node/103) kitchen metaphor of C++, Java and other languages.

  • Strike (unregistered) in reply to brazzy
    brazzy:
    Um... StringBuffer was introduced in Java 1.0, and it's actually StringBuilder these days.

    There is no StringBuilder in 1.4 and I believe JavaBuffer wasn't used as string-concatenator. I think it was hardcoded those days

    And what kind of dysfunctional project has you using 1.4, which is three years past EOL.

    J2ME, you know, mobiles before iPhone

  • (cs) in reply to trtrwtf
    trtrwtf:
    steenbergh:
    Damn, life must suck if you're chief architect for a language -- nay, a lifestyle -- you hate...

    Life does suck, often and hard. Case in point: Hey, Guido, I know you've been looking to move up, and there's good news and bad news. We need a chief architect for this new project. You'll get a (mumble)% raise and this, that, and the other thing, and life will be grand. The bad news is, it's a Java project.

    Suppose you're Guido. Let's say you have a few days to mull it over. What do you do?

    a) say "no thanks, I'll stick with my old salary and responsibilities and the language I prefer" b) say "yes, lovely, I'll take the raise and suck up the Java" c) quit and look for another job d) (a) or (b) and look for another job e) say "Okay, great, I can do that" and give up on your self-indulgent 'hatred' of Java, which after all is just another programming language with some nice safety features making it easier to manage large projects and some aggravating quirks which, as the architect, you won't be dealing with, they're mostly a problem for the programmer f) something else

    I've always found that learning a new language is fun in itself, once you get past the initial headache of having to get your head round shitloads of documentation (British shitloads, bigger than American shitloads, remember). Hating a language on principle is for cuntish little wankery losers. Wah wah wah, I doan WANNA learn java, er her ... ain't gonna get you looked at favourably when the opportunities are handed out.

  • (cs) in reply to frits
    frits:
    Jim Fell:
    This is a perfect example of why so many applications written in Java (and other high-level programming languages) are terribly inefficient. Most developers who have learned and written only in Java (or C#, etc.) don't have a basic understanding of what actually happens when their code is run. All programmers, regardless of the language they use, need to be aware of what the processor is doing when it executes an 'if' statement, or a 'switch', or when a function is called, etc.
    Actually, I love to not know. It almost always doesn't matter.

    I, on the other hand, love to at least have an idea, so i have a reasoning for why it almost always doesn't matter, and the ability to (based on this reasoning) point out situation when it does.

  • (cs) in reply to Strike
    Strike:
    Severity One:
    Anyway, Java does have operator overloading with the '+' operator, where 'a + b' is short for 'new StringBuffer(a).append(b).toString()'.

    Oh they introduced it?

    In 1.4 which I'm using there is no StringBuffer

    Bloody is. Might not be a StringBuilder but there's defly a StringBuffer.

  • (cs) in reply to trtrwtf
    trtrwtf:
    steenbergh:
    Damn, life must suck if you're chief architect for a language -- nay, a lifestyle -- you hate...

    Life does suck, often and hard. Case in point: Hey, Guido, I know you've been looking to move up, and there's good news and bad news. We need a chief architect for this new project. You'll get a (mumble)% raise and this, that, and the other thing, and life will be grand. The bad news is, it's a Java project.

    Suppose you're Guido. Let's say you have a few days to mull it over. What do you do?

    a) say "no thanks, I'll stick with my old salary and responsibilities and the language I prefer" b) say "yes, lovely, I'll take the raise and suck up the Java" c) quit and look for another job d) (a) or (b) and look for another job e) say "Okay, great, I can do that" and give up on your self-indulgent 'hatred' of Java, which after all is just another programming language with some nice safety features making it easier to manage large projects and some aggravating quirks which, as the architect, you won't be dealing with, they're mostly a problem for the programmer f) something else

    TRWTF is using the name Guido and not mentioning Trans Ams.

  • (cs) in reply to brazzy
    brazzy:
    Strike:
    In 1.4 which I'm using there is no StringBuffer
    Um... StringBuffer was introduced in Java 1.0, and it's actually StringBuilder these days.

    And what kind of dysfunctional project has you using 1.4, which is three years past EOL.

    <NelsonMuntz>HAA-ha!</NelsonMuntz>

    Wouldn't be surprised. A job I resigned my way out of was unshiftably 1.4 because it was built around a version of JBoss that wouldn't work in 1.5+. Had to be the shittiest application ever. Wonder if it's still running.

    <NelsonMuntz>HAA-ha!</NelsonMuntz>

  • Mr Keith (unregistered) in reply to Jim Fell
    Jim Fell:
    This is a perfect example of why so many applications written in Java (and other high-level programming languages) are terribly inefficient. Most developers who have learned and written only in Java (or C#, etc.) don't have a basic understanding of what actually happens when their code is run. All programmers, regardless of the language they use, need to be aware of what the processor is doing when it executes an 'if' statement, or a 'switch', or when a function is called, etc.

    So when you set out to bake a pie "from scratch" I assume you don't use a frozen crust, but rather start by planting wheat?

    Captcha: consequat, a tarter variety of kumquat. Better for pie.

  • jverd (unregistered) in reply to Jim Fell
    Jim Fell:
    This is a perfect example of why so many applications written in Java (and other high-level programming languages) are terribly inefficient.

    Please tell me you don't actually believe that, as stated, this is true, or even has any real meaning.

    Most developers who have learned and written only in Java (or C#, etc.) don't have a basic understanding of what actually happens when their code is run. All programmers, regardless of the language they use, need to be aware of what the processor is doing when it executes an 'if' statement, or a 'switch', or when a function is called, etc.

    To some extent, yes, it's good to understand the underlying issues that can make innocuous looking code unduly expensive to execute. But when all is said and done, the whole point of higher level languages is that they allow the programmer to focus more on the problem at hand and less on the fiddly mechanics. If the cost of that is longer execution times and higher memory usage, it's often a cost well worth paying thanks primarily to the enormous increases hardware bang for the buck over the last 4 decades.

  • (cs) in reply to big picture thinker
    big picture thinker:
    TRWTF is: Why would you ever want/need to get the ordinal from the Enum?

    The whole point of the enum is to substitute constant words for a magic numbers. Once you create the enum, you should use it throughout the entire program. It is an integer already, or more precisely it resolves to an integer automatically. There's no reason to perform a function like that.

    If the lead developer has a C background then he should be aware of something essentially the same as an enum; which is of course a preprocessor macro. Once you #define X 1, you can simply use X in place of 1 for both assignment and evaluations. You never even need to know or care about what X is.

    CAPTCHA: transverbero

    Jazz: An X, a 2, an X 2 3 4 ...

  • (cs) in reply to BentFranklin
    BentFranklin:
    TheRider:
    In fact, most people don't understand Java Enums. But that is not a reason to not use them, it is rather a reason to read the fucking manual.

    Clearly, you have read the fucking manual.

    That book is so wrong they have to invent a completely new category of incorrectness to hold it.

  • (cs) in reply to Matt Westwood
    Matt Westwood:
    big picture thinker:
    TRWTF is: Why would you ever want/need to get the ordinal from the Enum?

    The whole point of the enum is to substitute constant words for a magic numbers. Once you create the enum, you should use it throughout the entire program. It is an integer already, or more precisely it resolves to an integer automatically. There's no reason to perform a function like that.

    If the lead developer has a C background then he should be aware of something essentially the same as an enum; which is of course a preprocessor macro. Once you #define X 1, you can simply use X in place of 1 for both assignment and evaluations. You never even need to know or care about what X is.

    CAPTCHA: transverbero

    Jazz: An X, a 2, an X 2 3 4 ...

    I love that song...

  • (cs) in reply to Impaler
    Impaler:
    steenbergh:
    OJ:
    Also, I don't really get how anyone who has coded C for 20 years without realizing that it has enums has made it into manager position.
    He'll probably do less damage when further removed from a keyboard.
    It is very common - that kind of programmers are often promoted to "more human tasks" and become managers, so that real programmers can't do the job.

    ...as if you were not reading tdwtf properly. FTFY.

  • jverd (unregistered) in reply to Strike
    Strike:
    brazzy:
    Um... StringBuffer was introduced in Java 1.0, and it's actually StringBuilder these days.

    There is no StringBuilder in 1.4

    Nobody ever said there was.

    and I believe JavaBuffer wasn't used as string-concatenator. I think it was hardcoded those days

    You mean StringBuffer, I assume, and I have no idea what you think you mean by "it was hardcoded."

    Java has expanded + operations on Strings to StringBuffer.append() since at least 1.2, and probably back to 1.0. Starting in 1.4 or 1.5, it changed from StringBuffer to StringBuilder.

    And note that

    String s = x + y + z;
    

    has never been "inefficient". That expands to SB.append() calls, which are as efficient as one could write it out longhand. The problem comes in constructs like

    String s = "";
    while (...) {
      s += something;
    }
    

    Which cannot be expanded to a fixed number of append() calls on a single SB object, but instead requires creating at least an SB and a String for every iteration.

  • (cs) in reply to jverd
    jverd:
    And note that
    String s = x + y + z;
    

    has never been "inefficient". That expands to SB.append() calls, which are as efficient as one could write it out longhand. The problem comes in constructs like

    String s = "";
    while (...) {
      s += something;
    }
    

    Which cannot be expanded to a fixed number of append() calls on a single SB object, but instead requires creating at least an SB and a String for every iteration.

    Well you are wrong there budy.

  • tehR (unregistered)

    Well shit, I've been using enums the wrong way all this time.

    Captcha: ingenium - Diego's lead architect is a great example of when ingenium goes bad.

  • (cs) in reply to apoc9
    apoc9:
    In C++ enums are like named integers. However in Java they are full-fledged instances of class.
    They're more like named integers in plain C; in C++, you aren't allowed to treat them as integers without first casting them, and you can't do maths operations on them.
  • Tom (unregistered) in reply to Iscu
    Iscu:
    9 to 5 programmers, you gotta lov'em

    Usually, these are 9 to 10 programmers, or 4 to 5 programmers, or even 9 to 9:30 and 4 to 4:30 programmers.

    :-)

  • josefx (unregistered)

    Since ordinal() has been mentioned as the right way, for many things it is not. The ordinal depends on the declaration order and can be changed by refactoring or adding new values to an enum. So if the value should stay the same you have to use the following

    enum Test{
    False(0),True(1),FileNotFound(-1);
    public final int value; 
    Test(int v){value = v;}
    }
  • Tom (unregistered) in reply to DaveK
    DaveK:
    apoc9:
    In C++ enums are like named integers. However in Java they are full-fledged instances of class.
    They're more like named integers in plain C; in C++, you aren't allowed to treat them as integers without first casting them, and you can't do maths operations on them.

    That's why God invented Constants. Enums do absolutely nothing for c language that can't be done by constant declarations.

    /sarcasm

    My favorite feature is using enums for serialization. Named values make a lot more sense in an XML file than lots of 3's and 7's everywhere.

  • JAelwyn (unregistered) in reply to CodeRage

    They're also a great way to run out of PermGen space, if you use them too liberally. Though "too liberally" is generally on the scale of "data input" rather than "config file" quantities for most cases.

  • JAelwyn (unregistered) in reply to JAelwyn
    JAelwyn:
    They're also a great way to run out of PermGen space, if you use them too liberally. Though "too liberally" is generally on the scale of "data input" rather than "config file" quantities for most cases.

    Dammit, wrong button. That was in response to the "inter()ed[sic] Strings" comment.

  • Nagesh (unregistered) in reply to Nagesh
    Nagesh:
    Ralph:
    Jim Fell:
    All programmers, regardless of the language they use, need to be aware of what the processor is doing when it executes an 'if' statement, or a 'switch', or when a function is called, etc.
    I'm sorry, but that's a rather outdated attitude you're carrying around there, friend.

    Yes, long ago it was true you needed to understand a little something about the computer, but then we came up with these people called "users" who we encourage to know as little as possible, and even take pride in their ignorance, and we go all-out to make the software soooooooooo "easy to use" that even a drooling loonie can spastically click around and get something to happen. (Although if you know what you're doing, you'll find the emperor's new interface is actually harder to use.)

    And, now that our precious users are anointing themselves programmers too, we can't ask them to know anything there either.

    I am in agrement with you, partally. Sometime it is necesary to look under hood, sometime not required at all.

    Here in Hyderabad, "looking under hood" is dicouraged and often prohebited by laws.

  • Nagesh (unregistered) in reply to Strike
    Strike:
    Severity One:
    Anyway, Java does have operator overloading with the '+' operator, where 'a + b' is short for 'new StringBuffer(a).append(b).toString()'.

    Oh they introduced it?

    In 1.4 which I'm using there is no StringBuffer

    1.4 is being 10-year-old JDK.

  • Ganesh (unregistered) in reply to Nagesh
    Nagesh:
    1.4 is being 10-year-old JDK.

    In Pune, 10-year-old JDK is old enough to marry.

  • (cs)
    Could I Bother You to Recharge My Zune?:
    Jerry Sandusky:
    Ganesh:
    Nagesh:
    1.4 is being 10-year-old JDK.

    In Pune, 10-year-old JDK is old enough to marry.

    By golly, I better get over there then, asap.

    Signed,

    Jerry Sandusky, Assistant Coach, Penn State Askimet, you turd.

    Junior Dick Kid?

    Jerry's doxy knave

Leave a comment on “Bad News Enum”

Log In or post as a guest

Replying to comment #:

« Return to Article