The Artima Developer Community
Sponsored Link

Java Buzz Forum
Designing with exceptions

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Goldy Lukka

Posts: 1008
Nickname: xyling
Registered: Jan, 2004

Goldy Lukka is a Java Developer and an Entrepreneur. He is Founder of xyling.com.
Designing with exceptions Posted: Jul 12, 2005 1:04 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Goldy Lukka.
Original Post: Designing with exceptions
Feed Title: Xyling Java Blogs
Feed URL: http://www.javablogs.xyling.com/thisWeek.rss
Feed Description: Your one stop source for Java Related Resources.
Latest Java Buzz Posts
Latest Java Buzz Posts by Goldy Lukka
Latest Posts From Xyling Java Blogs

Advertisement
How do you decide when to use/throw exceptions and when not?
How do you decide which exception to use? Checked or Unchecked?
Should you define your own exception class or use an inbuilt (core Java API) one?

Hmm.. sounds quite like an extension to design patterns :)
Well, the article (found at the tile of this post) provides some general guidelines that can help you use exceptions in those situations where you've decided they are appropriate.

Here is a collection of the exception guidelines put forth by this article:

* If your method encounters an abnormal condition that it can't handle, it should throw an exception.

* Avoid using exceptions to indicate conditions that can reasonably be expected as part of the normal functioning of the method.

* If your method discovers that the client has breached its contractual obligations (for example, by passing in bad input data), throw an unchecked exception.

* If your method is unable to fulfill its contract, throw either a checked or unchecked exception.

* If you are throwing an exception for an abnormal condition that you feel client programmers should consciously decide how to handle, throw a checked exception.

* Define or choose an already existing exception class for each kind of abnormal condition that may cause your method to throw an exception.

The article gives several examples from the Java API that illustrate appropriate uses of exceptions. A must read for all and esp. the designers/architects.

[Resource-Type: Article; Category: Java/J2SE; XRating: 5]


Read: Designing with exceptions

Topic: A CruiseControl plugin for trac Previous Topic   Next Topic Topic: What Relational Database Management System to use for Enterprise Software Development

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use