[ 
https://issues.apache.org/jira/browse/MATH-1408?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15956641#comment-15956641
 ] 

Gilles commented on MATH-1408:
------------------------------

IMHO the examples given by Bruno are programming errors that should be caught 
at compile-time.
A quick look at the {{Frequency}} class gives the impression that all the 
fiddling is to allow usage of {{int}}, {{Integer}}, {{long}} and {{Long}} as 
key of the same {{Frequency}} instance.
What is a use-case for {{Comparable<?>}} rather than {{Comparable<T>}} (i.e. 
have the class be a bona-fide generic: {{Frequency<T>}}?

> Do not use exceptions for control flow
> --------------------------------------
>
>                 Key: MATH-1408
>                 URL: https://issues.apache.org/jira/browse/MATH-1408
>             Project: Commons Math
>          Issue Type: Task
>            Reporter: Gilles
>            Priority: Minor
>              Labels: control, exception, flow
>             Fix For: 4.0
>
>
> There are several occurrences where exception is used to control flow.
> Code such as
> {noformat}
> try  {
>  // block A
> } catch (ClassCastException e) {
>  // block B
> }
> {noformat}
> where "block A" is trying to cast an object "o" to "SomeClass", should be 
> changed to
> {noformat}
> if (o instanceof SomeClass)  {
>  // block A
> } else {
>  // block B
> }
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to