This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes System.out.println is Wrong?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "System.out.println is Wrong??" Watch "System.out.println is Wrong??" New topic
Author

System.out.println is Wrong??

Julio Cesar Marques
Ranch Hand

Joined: Mar 21, 2009
Posts: 66
Hi friends!

What is a best pratice in my catch blocks? (for dont lost poits)

1) catch (IOException e) {
System.out.println(......);
}

2) catch (IOException e) {
JOptionPane.message(......);
}

3) catch (IOException e) {
logger.log(ERROR, ....)
}

4) they don't care

Many thanks


Julio Cesar Lopes Marques
Sun Certified Java Developer 5, Sun Certified Java Programmer 5
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2258
    
    3

Fala ai Julio!!

In my opinion, it really depends on where you are. For instance, if you are in the business/services layer and an exception from a lower layer occurred there, you can log this exception and rethrow an exception that belongs to the business/services layer, with the lower level exception encapsulated in it. If you are in the last layer (for instance, the view layer), then you can log it and call JOptionPane.showMessageDialog, with JOptionPane.ERROR_MESSAGE.


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Julio Cesar Marques
Ranch Hand

Joined: Mar 21, 2009
Posts: 66
Grande Bob!!

So it's sounds good to me but to be honest i'm with a little lazy to do like this and i had hope you say "yeah put system.out in everyplaces and go on!" lol. But.... if i can do, i can do...

Best Regards!!
 
Don't get me started about those stupid light bulbs.
 
subject: System.out.println is Wrong??
 
Similar Threads
How to call a UNIX script froma java application on AIX (using Korn shell)?
Applet can write to, but not read from local file.
why not unreachable statement??
Doubt in Exception Catch
Which Exceptions a method can throw?