commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From S├ębastien Brisard <sebastien.bris...@m4x.org>
Subject [math] Is this good practice?
Date Mon, 10 Sep 2012 19:08:42 GMT
Hi,
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) {
            checkVectorDimensions(v);
            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,
S├ębastien


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


Mime
View raw message