Figuring out what went wrong
All of a sudden it seems as if everyone is talking about exceptions. Recent featured articles on java.net have
recommended everything from using them in a fine grained way to turning to a scripting language when you just need to get something done and don't want to worry about types or exceptions.
In Also in Java Today we link to Paul Philion's JavaWorld article Beware the dangers of generic Exceptions . His advice is simple but he backs it up with examples of what can go wrong in each case:
- Don't ignore exceptions
- Don't catch generic
- Don't throw generic
In the first case, he discusses the dangers of ignoring exceptions and then shows how and when you might do so if necessary.
The important thing about ignoring exceptions is ensuring that only a single method is wrapped in the ignoring try/catch block (so other methods in the enclosing block are still called) and that a specific exception is caught.
A problem with catching generic exceptions is that you end up with code that "catches exceptions it never intended to catch". In particular you will catch subclasses of
RuntimeException. One exception is when you want "to prevent a single exception from stopping an entire system. In situations where requests, transactions, or events are being processed in a loop, that loop needs to continue to process even when exceptions are thrown during processing. "
There are times when you write a line or two of code that could throw three or more exceptions. It is tempting to throw a generic
Exception to clean up the code, but Paul writes
even if the code is a little messy, at least it is explicit. Using the specific exception avoids a couple of very real problems: Throwing a generic
Exceptionhides the details of the underlying problem, thus removing the opportunity to deal with the real problem. Further, throwing a generic
Exceptionforces any call to that method to either catch that generic
Exception(which has problems, as discussed previously) or propagate the problem by rethrowing that generic
We also link to John Zukowski's developerWorks article on SpringLayout Manager . John shows how to use this simpler alternative to the
GridBagLayout to end up with attractive and flexible results in your Swing component design.
Michael Champion's Weblog entry Reports of the "Demise of the XML Database" are dubious says that SML DBMS has "been declared dead by those who would prematurely appropriate its inheritance." After explaining why he thinks the technology is still viable, Michael concludes with the warning that "it's important to consider the gap between technology mindshare among pundits and analysts, and technology deployment by businesses who need to get the job done efficiently and reliably.
In All things Blinky James Todd writes about performing routine actions remotely. He points to the Global Light Blinker project that aims to "create a world-wide JXTA GlobalLightBlinker PeerGroup which will allow people to experiment with remotely controlling embedded devices through the internet. "
Today in Projects and Communities, the Java Games community points to an article that says Games suffer from 'geek stereotype'. On the plus side the article argues that games have the "potential to change people's lives, offering them the chance to experience a wide range of emotions in a safe environment." The Java Web Services and XML community wiki features a page on the JAXb project . The page includes an introduction with feedback requesting for more details. Help provide a more complete introduction to JAXb.
In today's java.net News Headlines :
- Apache Cocoon Version 2.1.2 Released
- Analyst: Sun Should Spin Off Java, Cut Back on Sparc
- Jahia CMS and Portal Server 4.0 Released
- JFox 1.0DR3 Open Source J2EE Appserver Released
Registered users can submit news items for the
href="http://today.java.net/today/news/">java.net News Page using our
news submission form.
All submissions go through an editorial review by news director Steve
Mallet before being posted to the site. You can also subscribe to the href="http://today.java.net/pub/q/news_rss?x-ver=1.0">java.net News RSS
Current and upcoming Java Events:
- Oct. 7 Cocoon
- Oct 7-10 IDUG 2003 - Europe
- Oct. 8 JUG RU meeting
- Oct. 10-12 Lone Star Software Symposium
- Oct. 13 -15 ITU Telecom
Registered users can submit event listings for the
href="http://www.java.net/events">java.net Events Page using our
href="http://today.java.net/cs/user/create/e"> events submission form.
All submissions go through an editorial review before being posted to the
This blog is delivered weekdays as the
href="http://today.java.net/pub/q/java_today_rss?x-ver=1.0">Java Today RSS
feed. Once this page is no longer featured as the front page of href="http://today.java.net"> Java Today it will be archived at href="http://today.java.net/today/archive/index_10062003.html">
http://today.java.net/today/archive/index_10062003.html. You can
access other past issues in the href="http://today.java.net/today/archive/">java.net Archive.