Hi Sébastien. > > 2012/9/11 Gilles Sadowski <gil...@harfang.homelinux.org>: > > On Mon, Sep 10, 2012 at 08:47:35PM +0200, Sébastien Brisard wrote: > >> Hi > >> What should I do there? > > > > If we adopt the "flexible" policy (cf. other post), then you can do what you > > want. ;-) > > > This is absolutely what I do not want to do... I've already realized > that I've been too flexible on e.g. formatting this last year...
The flexible policy wrt null checks is that we concile the possibility to keep checking (for those who want to), and to not check. And from the user's perspective, both can be handled in the same way (because it is a NPE[1] that will be thrown, sooner or later). [From our perspective, CM will also be consistent albeit, depending on our positions, sometimes incomplete. The advantage of that policy is that, if we indeed want to fail as early as possible, we can just incrementally add precondition checks without changing the overall behaviour of the library: only the stack trace will become shorter...] Regards, Gilles [1] In CM 4.0, when we can change the inheritance tree for NAE. > Sébastien > > >> I'm trying to work on MATH-854. It turns out that FieldElement<T>.add > >> throws a NAE. Should I catch it below, and rethrow it with a more > >> detailed message (including the entry index)? > >> > >> Best, > >> Sébastien > >> > >> > >> /** {@inheritDoc} */ > >> 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)); > >> // SHOULD I CATCH NAE HERE? > > > > Not _catch_ NAE but _throw_ it; the line in the loop would become: > > > > final T entry = v.getEntry(i); > > if (entry == null) { > > throw new NullArgumentException(LocalizedFormats.INDEX, i); > > } > > out[i] = data[i].add(entry); > > > > > >> } > >> return new ArrayFieldVector<T>(field, out, false); > >> } > >> } > >> > > > > Regards, > > Gilles > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > > For additional commands, e-mail: dev-h...@commons.apache.org > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org