commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shriver, Daniel" <dshri...@mitre.org>
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 [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


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

Mime
View raw message