commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From S├ębastien Brisard <>
Subject [math] Is this good practice?
Date Mon, 10 Sep 2012 19:08:42 GMT
I thought it was not good practice to rely on exception in
unexceptional circumstances. In ArrayFieldVector, there are numerous
occurences of the following pattern

    public FieldVector<T> add(FieldVector<T> v)
        throws DimensionMismatchException {
        try {
            return add((ArrayFieldVector<T>) v);
        } catch (ClassCastException cce) {
            T[] out = buildArray(data.length);
            for (int i = 0; i < data.length; i++) {
                out[i] = data[i].add(v.getEntry(i));
            return new ArrayFieldVector<T>(field, out, false);

The "catch (ClassCastException cce)" seems uggly to me. Should I file
a JIRA issue and start replacing with instanceof?
Best regards,

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

View raw message