[Yanel-dev] XMLHelper added
Guillaume Déflache
guillaume.deflache at wyona.com
Fri Oct 10 09:22:04 CEST 2008
Michael Wechner schrieb:
> The Wyona commons lib contains some new XML helper/utility methods
A few comments on
https://svn.wyona.com/repos/public/commons/trunk/src/java/org/wyona/commons/xml/XMLHelper.java
follows:
Why using arrays in interfaces, and not Iterable (Java 1.5+) or Iterator
or Collection?
Please avoid implementation-specific classes as parameters: HashMap ->
Map: what if wanted to give the method a sorted map?
Can someone explain to me what the use case for isFragment is? ...or
even write a unit test! :)
> if( document == null ){
> log.warn("document to string called with a null document!, don't do this.");
> return null;
> }
>
I would rather throw a NPE right here with the same comment than getting
it in a maybe distance place!
BTW shouldn't we always rethrow exceptions as runtime ones in helper
classes? Do we otherwise have an exception handling policy?
> I am currently trying to refactor this, whereas I want to write tests
> first for the existing code, before actually substituting with the
> helper methods.
It would definitely be better to have tests 1st, if only to see how the
APIs work out/feel in practice in the test cases' code, esp. as regards
exception handling.
More information about the Yanel-development
mailing list