On Tue, 14 Jan 2003 13:31:03 -0500 (EST), [EMAIL PROTECTED] wrote:

>One final issue: I was using javax.usb.NotActiveException for certain
>methods.  However, there is also a java.io.NotActiveException.  I had
>changed to use that Exception, but it may be better to use a 
>javax.usb.NotActiveException...?

        It would be best to have something in javax.usb., but with a
different name (perhaps USBNotActiveException).  This is for two
reasons:

        1) As some users will want to use existing stream classes with
their open USB ports, there is the possibility for a name-space
collision if the developer just indiscriminately imports everything
from both java.io and javax.usb.  Thus, if they do something like...

        import java.io.*;
        import javax.usb.*;

        ...

        try {
           ...bunch of USB and IO stuff that could throw one or the
other type of NotActiveException...
        } catch (NotActiveException e)  <-- which
"NotActiveException" class 
                                        are we catching here?

        Now I suppose there are two schools of thought on this -- that
the developer should be smart enough to avoid issues like this, and can
fix it when the compiler complains about it vs. setting things up to
prevent problems for the slightly careless developer.  Personally, I
lean (ever so slightly) towards the latter in this case.

        2) Sun's API description for java.io.NotActiveException
specifically states that the exception is thrown due to object
serialization not being active and/or available.  This isn't how Java
USB will be using it, hence it doesn't really make sense to do so.

        (Now I suppose that you could solve #1 by making
javax.usb.NotActiveException a direct subclass of
java.io.NotConnectedException, but if you're going to be creating your
own exception class anyhow, it might as well not be dependent on what
is in reality an unrelated class.  I'd consider that a pretty bad
design, even though it is an interesting work-around).

Brad BARCLAY


=-=-=-=-=-=-=-=-=
>From the OS/2 WARP v4.5 Desktop of Brad BARCLAY.
E-Mail:  [EMAIL PROTECTED]  Web:  http://www.jsyncmanager.org




-------------------------------------------------------
This SF.NET email is sponsored by: Take your first step towards giving 
your online business a competitive advantage. Test-drive a Thawte SSL 
certificate - our easy online guide will show you how. Click here to get 
started: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0027en
_______________________________________________
javax-usb-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/javax-usb-devel

Reply via email to