• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Question about static methods

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I've just read this article http://java.dzone.com/news/application-logging-what-when,
and it suggests that exceptions should be handled in one place.


My question is that, is handleException method be synchronized? Like in a Swing app where there a separate threads that do I/O.

thanks!
-
thirdy
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vicente de Rivera III wrote:
My question is that, is handleException method be synchronized?


I think no need, that method simply gonna logs out the exception, simplifying the the single method for logging exceptions.
 
Vicente de Rivera Iii
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks
 
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, it depends on what you do in that method. I can think of a couple scenarios where even simple logging gets messed up if that call isn't synchronized in some way. On that note, I'm not sure I agree with the suggestion that all exceptions have to be handled in one place.
 
Vicente de Rivera Iii
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Making it synchronized won't hurt much right?

I just read this article, http://www.javaworld.com/javaworld/jw-11-2007/jw-11-exceptionset.html

I guess for simple apps, handling exceptions in one place is good. But for business apps, exceptions might be needed by the caller.
Any comment on this?

And any other great articles like these? Prior to reading these articles, I didn't even really consider writing my own Exceptions.
Or a book that guides you on developing a real-world Java app with with good practices such as designing your own Exceptions?
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

R van Vliet wrote:Well, it depends on what you do in that method. I can think of a couple scenarios where even simple logging gets messed up if that call isn't synchronized in some way.


I agree, synchronizing the code is totally depends upon what you're doing in that method, but the author is talking about the simple logging process and hes emphasizing more handling exception logging in single place, but not about the whether it should be synchronized one or not.

I guess for simple apps, handling exceptions in one place is good. But for business apps, exceptions might be needed by the caller.
Any comment on this?


Now that's depends upon the app process/design, whether caller wants the exception should be handled by himself or not.
 
I don't always make ads but when I do they're tiny
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic