commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shriver, Daniel" <>
Subject RE: [Math] Allow empty "ConvexHull2D"
Date Mon, 01 Jun 2015 12:56:53 GMT
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)
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

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).

-----Original Message-----
From: Gilles [] 
Sent: Monday, June 01, 2015 8:38 AM
Subject: [Math] Allow empty "ConvexHull2D"


I have a question regarding

public Region<Euclidean2D> createRegion() throws 

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 
(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 
transformation until it is indeed impossible to compute the hull; it 
that it would be interesting to not treat that as a hard-failure 
an exception).


To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message