On Tue, Sep 4, 2012 at 9:01 AM, Gilles Sadowski <
gil...@harfang.homelinux.org> wrote:

> Hi.
>
> >
> > FindBugs can give warnings like:
> >
> > Switch statement found in
> > org.apache.commons.codec.binary.Base32.decode(byte[], int, int,
> > BaseNCodec$Context) where default case is missing
> >
> > In this case for [codec], it looks like the code was carefully
> constructed
> > and that no default clause is needed.
> >
> > In these cases for any component, this FindBugs issue feels like a style
> > issue, is it worth changing the code to add a default clause like:
> >
> >    default:
> >       // ok to fall through for other values.
> >       break;
> >
> > Or does this feel like noise to you all?
>
> In Math, there is this kind of code:
> ---CUT---
>                 switch (method) {
>                 case ILLINOIS:
>                     f0 *= 0.5;
>                     break;
>                 case PEGASUS:
>                     f0 *= f1 / (f1 + fx);
>                     break;
>                 case REGULA_FALSI:
>                     // Detect early that algorithm is stuck, instead of
>                     // waiting
>                     // for the maximum number of iterations to be exceeded.
>                     if (x == x1) {
>                         throw new ConvergenceException();
>                     }
>                     break;
>                 default:
>                     // Should never happen.
>                     throw new MathInternalError();
>                 }
> ---CUT---
>
>
What about the opposite case:

We do not care about the other values than the ones in each switch case.

Gary


>
> Gilles
>
> >
> > Gary
> >
> > --
> > E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> > JUnit in Action, 2nd Ed: <http://goog_1249600977>http://bit.ly/ECvg0
> > Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
> > Blog: http://garygregory.wordpress.com
> > Home: http://garygregory.com/
> > Tweet! http://twitter.com/GaryGregory
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
> For additional commands, e-mail: dev-h...@commons.apache.org
>
>


-- 
E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
JUnit in Action, 2nd Ed: <http://goog_1249600977>http://bit.ly/ECvg0
Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Reply via email to