commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <>
Subject RE: [general] throw exception OR return value
Date Thu, 13 Mar 2003 13:43:09 GMT

Throw an UnsupportedOperationException.  It's what we do in jakarta, and
what the JDK tries to do, at least with the collections classes which
are a good example for these types of interfaces (e.g. some concrete
class doesn't support addAll(Collection c)).

Yoav Shapira
Millennium ChemInformatics

>-----Original Message-----
>From: John Keyes []
>Sent: Wednesday, March 12, 2003 6:24 PM
>To: commons-dev
>Subject: [general] throw exception OR return value
>This is I suppose something covered by a best practice, so I would like
>to hear what people think.
>If I have an instance that implements an interface, but does not need
>to implement all of the methods, is it better to return a value or
>throw an exception.
>For example, if I had an interface building, and two concrete classes,
>House and Shed.  The method getGarageSize would possibly be
>meaningful for House, but definitely not for Shed.  So would it be
>better for getGarageSize to return null or throw an Exception.
>This situation may arise because the interface is poorly designed, but
>say you want to add functionality to a codebase, and not modify the
>existing APIs.
>-John K
>- - - - - - - - - - - - - - - - - - - - - - -
>Jakarta Commons CLI
>To unsubscribe, e-mail:
>For additional commands, e-mail:

This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged.  This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender.  Thank you.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message