• mjenks (unregistered)

    This all looks fine to me. This looks like my code on a good day.

  • CornedBee (unregistered)

    These are quite nice. Of course, I see one of them ALL the time!

    if(condition == true) {
    return true;
    } else {
    return false;
    }

    Sadly, I had to deal with code like that a lot lately.

  • Daniel T (unregistered) in reply to CornedBee

    This crap has to be intentional.  It's just too freaking complicated to be an accident (how could he not have learned "int i = 1"?).  He probably hates you and/or the project, and this is how he's doing.  I think the javadoc proves that...


    --Daniel T

  • Gusti (unregistered) in reply to BACON
    BACON:

    Personally, I think the following would have been a lot more prudent...

    <font size="2"><font face="Lucida Console"><font color="#0000ff">if</font> (obj1.<font color="#0000ff">equals</font>(obj2) == <font color="#0000ff">true</font> && obj2.<font color="#0000ff">equals</font>(obj1) == <font color="#0000ff">true</font>)</font></font>
    <font size="2"><font face="Lucida Console"><font color="#0000ff">      return true<font color="#000000">;</font>
    </font></font></font>


    ...or maybe even...

    <font size="2"><font face="Lucida Console"><font color="#0000ff">if</font> (obj1.<font color="#0000ff">equals</font>(obj2) == <font color="#0000ff">true</font> && obj2.<font color="#0000ff">equals</font>(obj1) == <font color="#0000ff">true</font> && <font color="#0000ff">true</font> == <font color="#0000ff">true</font> && <font color="#0000ff">true</font> != <font color="#0000ff">false</font>)</font></font>
    <font size="2"><font face="Lucida Console"><font color="#0000ff">      return <font color="#000000"><font color="#0000ff">true</font>;</font>
    </font></font></font>


    You can never be too careful, particularly when it comes to your definition of "equivalency".



    He he he he he he .... :|
    This is too funny
    Last time i laughed like this was when i read the Windows 95 source code ( if(started) { crash(); } // and more like this )

  • AC (unregistered) in reply to bjmarte
    bjmarte:
    znaps:

    This one is my favourite for sheer demonstration that he doesn't have a clue about any of the language features.


    <FONT face="Lucida Console, Courier" size=2>
    <FONT color=#0000ff>public boolean</FONT> compareObjects(<FONT color=#0000ff>Object</FONT> obj1 , <FONT color=#0000ff>Object</FONT> obj2) {
    <FONT color=#0000ff>if</FONT> (obj1.<FONT color=#0000ff>equals</FONT>(obj2) == <FONT color=#0000ff>true</FONT>)
    <FONT color=#0000ff>return true<FONT color=#000000>;</FONT>
    else
    return false</FONT>;
    }
    </FONT>
     

    This is my favorite just because of the absolute ignorance of basic programming concepts displayed.

    1) Right off the bat you don't even need this function because it is exactly what the equals function does.

    2) Ok, bad enough he wrote a function for it but they didn't even just return the value of the equals function. Nope, gotta write an if statement around it to check the value.

    3) Ok, bad enough he used an if statement to check which boolean value to return but the coder has to check the return value of the equals function within the condition of the if statement itself.

    I've never seen more idiotic code.

     

    Not to support code like this, but I can see a "reason" for something like this. What if they were converting a large project of C++ code (that as I recal doesn't have a .equals method for all objects). So there could have been a ton of calls to "compareObjects", and instead of changing them to the "if (obj1.equals(obj2) == true)" they could leave the existing code intact. I'll admit I've done things like this when converting projects between languages (for phase 1 mind you).

    Granted, I would just have done "return obj1.equals(obj2)" unless I was planning on doing something later on.

  • Ernest (unregistered) in reply to dubwai

    It may be stupid, but it compiles under:

     bash-2.05b$ java -version
    java version "1.4.2"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2)
    Classic VM (build 1.4.2, J2RE 1.4.2 IBM build cxia321420-20040626 (JIT enabled: jitc))

    What I thought should work doesn't:

    bash-2.05b$ javac JBookmarkSync.java
    ./BookmarkBucket.java:69: cannot resolve symbol
    symbol  : method put (int,java.net.URL)
    location: class java.util.Hashtable
                    urlHash.put(BM.getURL().hashCode(), BM.getURL());
                           ^
    1 error

  • Cristian (unregistered) in reply to Stephan Rose
    Stephan Rose:
    float value1 = 1.0f; double value2 = double.Parse(value1.ToString());
    You know, the float to double part is (somewhat) justifiable! If the float would've had decimals, it would get messed up by simply "(double)value1"-ing it... One alternative however would be (double)(decimal)value1, but i don't particularly like decimals instead of strings...

    Just my 2c.

  • Anonymous (unregistered) in reply to Cristian
    Cristian:
    Stephan Rose:
    float value1 = 1.0f; double value2 = double.Parse(value1.ToString());
    You know, the float to double part is (somewhat) justifiable! If the float would've had decimals, it would get messed up by simply "(double)value1"-ing it...

    Wut.

  • (cs)

    It makes me rather sad to see that back in 2005, nobody here complained about typos like they do now. "Purising"? Pretty sure that's not a word, not that anyone is likely to care, a jillion year after this was posted.

Leave a comment on “Friday Java Jumble”

Log In or post as a guest

Replying to comment #:

« Return to Article