xerces-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jojakim Stahl" <js_l...@inpra.de>
Subject RE: even more crashes
Date Thu, 02 Nov 2000 18:15:28 GMT
In general you are right and I don't want you to add "if (!ref)" checks to
Xerces. And I agree that it is better to have an app die as response to
invalid calls or other malformed execution at development time. I only tried
to point out that if a programmer looks at a line with node.function()
syntax on the first view doesn't expect a NullPointerException be raised as
an response to a NULL reference.

But if you would have to use the node->function() syntax it would be obious
to almost every programmer that *he* has to check for NULL references and
that they may occure at all.


> -----Original Message-----
> From: John Ky [mailto:hand@syd.speednet.com.au]
> Sent: Wednesday, November 01, 2000 5:34 AM
> To: xerces-c-dev@xml.apache.org
> Subject: Re: even more crashes
> > As one uses the . operator instead of ->, it implicates that you have
> > actually an object where you are calling on, and no reference. By
> internally
> > using a reference (actually only calling something like ref->normalize()
> > from node.normalize()), in my opinion Xerces gets responsible for doing
> the
> > if (!ref) check.
> And what would you have done in when if (!ref) holds true?
> > At all, the node variable is not declared as a C++ reference
> and therefore
> > in normal circumstances would always be a valid object and no
> one expects
> a
> > Null-Pointer-Exception by calling a method on it.
> Initialisation errors should always be caught early and dying
> would do more
> good than either doing nothing or throwing an exception because
> that forces
> the programmer to check that the code is infact correct.
> There is nothing worse than a programmer forgetting to initialise the node
> object and calling it as if it was initialised.  Xerces does what's best
> IMO,
> because these programming errors are hard to catch.
> NullPointerExceptions are almost always programming errors - why
> should they succeed in any way?
> What are ASSERTIONS for anyway?  Don't people use it to make
> their applications die in development rather than production release?
> The only "if (!ref)" check that should be performed by Xerces IMO,
> would be to formalise the fact that the operation is invalid:
> ASSERT(fImpl != 0);
> Perhaps no one is responsible for knowing a function call causes
> a NullPointerExeption.  But they are certainly responsible for
> using an API correctly.  Xerces does programmers a service
> by dying when it knows it has been called incorrectly and by
> providing a means to check preconditions ie if (node ==
> NULL).  Making assumptions about how users want errors
> handled is the worst Xerces can do.
> -John
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org

View raw message