*
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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP 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: 67
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: 2266
    
    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: 67
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!!
 
 
subject: System.out.println is Wrong??