Hey Martin, -----Original Message-----
From: Martin Desruisseaux <[email protected]> Organization: Geomatys Reply-To: "[email protected]" <[email protected]> Date: Saturday, March 30, 2013 1:00 PM To: "[email protected]" <[email protected]> Subject: Re: On null collections >Hello Chris > >Le 30/03/13 00:35, Mattmann, Chris A (388J) a écrit : >>> (...snip...) >>> However DataQuality [1] have another property, "lineage", and ISO 19115 >>> said that those two properties are mutually exclusive. If the "lineage" >>> property is set, what should getReports() returns? >> How about Collections.unmodifiable{List|Map|etc}? > >In this context, it would be Collections.empty{Set|List}. The point was >that we could see a nuance between "no elements", and "elements can not >exist here in current context". In the first case, users can add >elements. In the second case, they can not. Returning a null value in >the second case would be a way to differentiate them. Well that's my point -- Collections.unmodifiableList [1] for example, handles the 2nd case well and would avoid having to return null (and the XML marshaling issue you mention below). Right? Or am I missing something? > >Returning Collections.empty{Set|List} means that it is not worth to >distinguish those two possibilities, which is a perfectly valid decision >for keeping the API simpler. Eventually, the exception thrown by >Collection.add(...) could contains a message saying why elements can't >be added. Isn't that just replicating what [1] does? > >Returning null make the job a little bit easier in some situations like >XML marshalling, where empty XML element is not the same than no XML >element. But this can be considered as an implementation details. Yep agreed -- let me know what you think. Cheers, Chris [1] http://s.apache.org/Dnu ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Chris Mattmann, Ph.D. Senior Computer Scientist NASA Jet Propulsion Laboratory Pasadena, CA 91109 USA Office: 171-266B, Mailstop: 171-246 Email: [email protected] WWW: http://sunset.usc.edu/~mattmann/ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Adjunct Assistant Professor, Computer Science Department University of Southern California, Los Angeles, CA 90089 USA ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
