Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (429)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (468)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Sloppy JRE code?  (Read 1298 times)
0 Members and 1 Guest are viewing this topic.
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Posted 2003-12-23 17:59:00 »

Just looked at setBackground() in JComponent..
1  
2  
3  
4  
5  
6  
7  
8  
9  
public void setBackground( Color bg )
{
    Color oldBg = getBackground();
    super.setBackground(bg);
    if( (oldBg != null) ? !oldBg.equals(bg) : ((bg != null) && bg.equals(oldBg)) )
    {
        repaint();
    }
}


Any idea why you would call bg.equals(oldBg) when you KNOW that oldBg is null and bg is not?Huh

I know this won't cost much.. but it just seems sloppy.

Offline Jeff

JGO Coder




Got any cats?


« Reply #1 - Posted 2003-12-23 18:27:11 »

Overly complex C code like this always scares me that I'm missing something in the order or of precedence, but my take is you are right.

My suspicion is that this code probably had multiple authors and was written at multiple times.  When the second (or later) author did their work they introduced a redundancy they didn't realize was there because they didn't totally grok the original coder's work.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #2 - Posted 2003-12-23 18:41:34 »

Quote
Overly complex C code like this...


Ahem... that's JAVA  Grin

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jeff

JGO Coder




Got any cats?


« Reply #3 - Posted 2003-12-23 19:38:26 »

Your right. My mistake.

I didn't know we HAD the trinary operator in Java Smiley

Same observation about overly complex statements though.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline cfmdobbie

Senior Member




Who, me?


« Reply #4 - Posted 2004-01-01 20:08:55 »

Quote
I didn't know we HAD the trinary operator in Java Smiley


Oh, man, I use it all the time... Grin

Best. Operator. Ever.

Hellomynameis Charlie Dobbie.
Offline Markus_Persson

JGO Wizard


Medals: 12
Projects: 19


Mojang Specifications


« Reply #5 - Posted 2004-01-01 21:04:12 »

System.out.println("It can be very "+(isTrinaryUseful()?"useful":"confusing")+" when building debug strings, so I use it all the time.");

Play Minecraft!
Offline Jeff

JGO Coder




Got any cats?


« Reply #6 - Posted 2004-01-01 22:29:24 »

lol


Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

theagentd (6 views)
2014-04-24 23:00:44

xsi3rr4x (83 views)
2014-04-15 18:08:23

BurntPizza (75 views)
2014-04-15 03:46:01

UprightPath (86 views)
2014-04-14 17:39:50

UprightPath (69 views)
2014-04-14 17:35:47

Porlus (86 views)
2014-04-14 15:48:38

tom_mai78101 (109 views)
2014-04-10 04:04:31

BurntPizza (169 views)
2014-04-08 23:06:04

tom_mai78101 (265 views)
2014-04-05 13:34:39

trollwarrior1 (217 views)
2014-04-04 12:06:45
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!