[geos-devel] FW: [jts-devel] Node invariant

Mateusz Łoskot mateusz at loskot.net
Sun Apr 9 22:31:02 EDT 2006


Martin Davis wrote:
> You're right, Node assumes that the EdgeEndStar argument is non-null.
>  (By the way, there definitely is a concept of null in Java, and it's
>  used in exactly the same way that a null pointer is used in C++)

Yup, null pointer is similar to null reference.

> Node was never written to be a general-purpose class, so not too much
>  attention was paid to hand-holding. It is assumed that the client
> uses the class correctly.

So, it's similar std::vector or many other classes, which expec their
client uses them in reasonable way. And the client is responsible to
test data it is going to send to the instance of this class.

> In Java this is self-detecting, since any use of a null pointer will
> cause a nice exception to be thrown.  I guess this isn't the case in
> C++, so maybe you need to check for null.  (However, there maybe be
> valid uses of node which have a null edges reference, so you'll have
> to check for it on use, not construction)

So, I'd leave Node as is but *make sure* that every its client does the
job and checks all data it is going to send to the Node.
This will make it possible that some clients will send only-valid 
objects but some - what's correct according to particular semantic - 
will be able to send null-pointer.

Cheers
-- 
Mateusz Łoskot
http://mateusz.loskot.net



More information about the geos-devel mailing list