Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Question about static methods

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
thanks
 
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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.
 
The problems of the world fade way as you eat a piece of pie. This tiny ad has never known problems:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic