> -----Original Message-----
> From: Takuya Murata [mailto:[EMAIL PROTECTED] 
> Sent: 20 August 2003 04:29
> To: Jakarta Commons Developers List
> Subject: Re: [collections] Questions....
> 
> 
> Hi,
> 
> So the question is do we really need SingletonIterator and 
> such. If we 
> want to eliminate the number of methods or classes, then what 
> about one 
> class for all of collections or iterators? I suppose the use of 
> singleton methods and classes is almost always to provide an object 
> matching a data type you want. Thus, we can have a class like
> 
> class Singleton implements List, SortedSet, Bag, Iterator, 
> ListIterator 
> {
> }

this sounds hugely dangerous - the javadocs for List#equals(Object) for
example stipulate:
Compares the specified object with this list for equality. Returns true if
and only if the specified object is also a list, both lists have the same
size, and all corresponding pairs of elements in the two lists are equal.
(Two elements e1 and e2 are equal if (e1==null ? e2==null : e1.equals(e2)).)
In other words, two lists are defined to be equal if they contain the same
elements in the same order. This definition ensures that the equals method
works properly across different implementations of the List interface.

whereas Set#equals(Object) state:
Compares the specified object with this set for equality. Returns true if
the specified object is also a set, the two sets have the same size, and
every member of the specified set is contained in this set (or equivalently,
every member of this set is contained in the specified set). This definition
ensures that the equals method works properly across different
implementations of the set interface.

This is only one of many conflicts.

Just implementing the method signatures of such classes without implementing
their 'contracts' (even if the contract is only the official line on what
they should and shouldn't do) is a recipe for confusion and bugs...

Matt
 
**************************************************************************
The information transmitted herewith is sensitive information intended only
for use by the individual or entity to which it is addressed. If the reader
of this message is not the intended recipient, you are hereby notified that
any review, retransmission, dissemination, distribution, copying or other
use of, or taking of any action in reliance upon this information is
strictly prohibited. If you have received this communication in error,
please contact the sender and delete the material from your computer.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to