I have another short "Java Programming In General" question. (All of
these questions are related to my work on the JTSWarped Library, so I
hope it will be useful to OpenJUMP developers at some point in the
future.)

When is it appropriate to validate mathod arguments when using a Java
library? Should this be done by the client code that uses the library
BEFORE arguments are passed to the library code, or should it be done
AFTER the client code has made the method call, within the library
code?

For example: JTSWarped has code that will accept a String representing
an angle in Degrees-Minutes-Seconds format that returns the same angle
in Decimal Degrees format. Should I check for a valid String argument
within this method, or should I indicate that this responsibility
belongs to the client code?

Here is why I ask. I've been reading about the proper use of Java
Exceptions. Most of the material I've read seems to indicate that
Exceptions generated by improper use of an API (invalid method
arguments as an example) should throw unchecked Exceptions. This makes
sense if the client code is responsible for the validity of method
arguments. If the library code is responsible, it seems more
reasonable to throw checked Exceptions.

Thanks for any comments or advice.

The Sunburned Surveyor

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to