Lists Home |
Date Index |
- From: Jarle Stabell <firstname.lastname@example.org>
- To: "'email@example.com'" <firstname.lastname@example.org>
- Date: Wed, 17 Feb 1999 16:40:38 +0100
David Megginson wrote:
> As I just mentioned in a reply to Don, exceptions provide for cleaner
Generally I agree.
> and they help avoid bugs by enabling more compile-time checking.
I haven't used Java much, so personally I don't know whether I find this
forced declarations of exception throwing a good thing.
(It seems to me quite a lot of people throws in the towel and just writes
> It's easy to write
> parser.setFeature("org.xml.sax.features.namespaces", true);
> and forget to check the return value, but it's harder to forget to
> catch an exception.
True. But in this case, if the parser-client wants to trade features based
upon what is supported or not, I guess you really need to inspect (and
perhaps store the result) for each particular feature, whether it was
supported or not (or just set it in case it is supported, and don't care if
it is not).
Then this part of the code becomes somewhat uglier with exceptions.
If the typical case is (f.i.) : "I want Namespaces, X-Link, X-Schema and
X-Pointer, and if I don't get all of these, I won't use you" (ie a
conjunctive condition), then exceptions works very well, but if you don't
want to throw in the towel the moment a single feature is not supported,
exceptions could give uglier code than without them.
Of course, this mail is only about minor details which doesn't matter much.
If one needs to do a "lot of" reasoning based upon which features are
supported, it is trivial to make a wrapper function which transforms the
exception (or not) into a boolean value.
xml-dev: A list for W3C XML Developers. To post, mailto:email@example.com
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:firstname.lastname@example.org the following message;
To subscribe to the digests, mailto:email@example.com the following message;
List coordinator, Henry Rzepa (mailto:firstname.lastname@example.org)