commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From __matthewHawthorne <>
Subject Re: [collections] Questions....
Date Wed, 20 Aug 2003 04:58:01 GMT
I think that the elimination of _unnecessary_ methods and classes is a
noble goal.  

For example, In the SingletonIterator vs. SingletonListIterator
situation, as long as the logic to implement the extra methods specified
by java.util.ListIterator does not cause significant performance
overhead, it seems reasonable to use SingletonListIterator as a standard
Iterator also.  (I'm pretty sure that's what is being suggested.)

However, I don't agree with elimination just for elimination's sake,
which is how I interpret the suggestion of defining a single class which
implements List, SortedSet, Bag, Iterator, ListIterator, etc.  I find it
simpler to allow each class to perform a single task, and perform it
well, then to force it to perform the job of 5 classes.  I don't see the
benefit of such a solution.  In my opinion, smaller, simpler classes are
easier to write, easier to maintain, easier to test, and easier to use.


On Tue, 2003-08-19 at 20:28, Takuya Murata wrote:
> 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 
> {
> }
> Although it is usually bad practice to aggregate several different 
> functionalities into one class, in this case, it might be fine.
> Yes, this is in line with your proposal; we can use 
> SingletonListIterator for both Iterator and ListIterator. I think the 
> problem of this solution is users probably expect SingletonIterator 
> intuitively and might be puzzled why there is no such.
> Takuya Murata
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

View raw message