commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles <gil...@harfang.homelinux.org>
Subject RE: [Math] Allow empty "ConvexHull2D"
Date Mon, 01 Jun 2015 21:26:48 GMT
On Mon, 1 Jun 2015 12:56:53 +0000, Shriver, Daniel wrote:
> Personally, I'd think having an exception is "better" in this case.
> 1) the computation is fundamentally invalid, an exception conveys
> this well (the same thing is used with other invalid computations 
> like
> division by zero)

When points are gradually removed from a set, the hull of the set
gradually shrinks until it becomes a line. IIUC that line would be
equivalent to an empty region (in 2D space).
Hence, I think that returning an empty region is more logical than
raising an exception.

> 2) an empty region could be a valid result of some valid operation
> (unless you are suggesting creating some "invalid region" that just
> conveys the same info- that an exception occurred) this effectively
> masks the fact that an invalid operation occurred

I don't propose such an "invalid region".
An "empty region" is a valid region.

> A programmer can and should catch exceptions from invalid
> computations.  They should be able to decide if they want to "ignore"
> the problem (such as create something like an empty region) and
> continue on, or if they want to follow some other path (halting work,
> logging a problem,...).  If you return some valid "empty region" you
> would mask the exception (or if it is only for invalid computations
> you'd be simply recreating it as something other than an exception).

Cf. above.  I see it the other way around (any set operation is
meaningful even when applied to an empty set), there is no need
to consider it invalid: if the *caller* does not expect an "empty"
result, he should check and act (i.e. raise an exception).

In my use-case, the shape shrinks, then disappears, than reappears
and grows again, in a "continuous" way; nothing "exceptional" occurs.
If I want apply some geometrical operation to the region that encloses
the shape why should the code handle differently empty and non-empty
regions?


Gilles

> -----Original Message-----
> From: Gilles [mailto:gilles@harfang.homelinux.org]
> Sent: Monday, June 01, 2015 8:38 AM
> To: user@commons.apache.org
> Subject: [Math] Allow empty "ConvexHull2D"
>
> Hi.
>
> I have a question regarding
>
> public Region<Euclidean2D> createRegion() throws
> InsufficientDataException
>
> in ConvexHull2D.
> It throws the exception when the number of points is < 3.
>
> One can imagine that rather than aborting it could return an "empty
> Region"
> (which would seamlessly work with further operations on the Region).
>
> What do you think?
>
> Context: in the course of a program, a "valid" region can undergo
> successive
> transformation until it is indeed impossible to compute the hull; it
> seems
> that it would be interesting to not treat that as a hard-failure
> (warranting
> an exception).
>
>
> Regards,
> Gilles



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message