commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Moore" <tmo...@blackboard.com>
Subject RE: [Collections][SUBMIT] TypedList
Date Tue, 23 Apr 2002 20:02:49 GMT
> -----Original Message-----
> From: Stephen Colebourne [mailto:scolebourne@eurobell.co.uk] 
> Sent: Tuesday, April 23, 2002 3:58 PM
> To: Jakarta Commons Developers List
> Subject: Re: [Collections][SUBMIT] TypedList
> 
> 
> 
> From: Henri Yandell <bayard@generationjava.com>
> > > > What is the point of the wrap method?
> > > >
> > > > Can I do:
> > > >     List list = TypedList(new LinkedList());   ????
> > >
> > > Yes, but the syntax is
> > > List list = TypedList.wrap(new LinkedList());
> > > However, as noted above, the iterator is based on 
> AbstractList - not
> much
> > > use for LinkedList. I'll see if I can fix this ;-)
> >
> > Little unsure what you're saying. Sounds like the only 
> difference is 
> > that you use a factory method where I tend to use a constructor. I 
> > love doing:
> >
> > List list = new LimitedList( new SortedList( new LinkedList() ) );
> 
> The specification for List (and other collections) 'requests' 
> that all implementations should have a constructor that takes 
> in a Collection object (to do an addAll). I was respecting 
> this by not confusing the constructors. Also, I may need 
> constructors to do the simple instanceof check, thus named 
> statics work more easily.

I'd argue that this is a reasonable place to vary the convention.  This
class isn't really a collection itself, but a proxy for other
collections.  There isn't really any precedent for that in the J2SE, or
even in the rest of the commons collections framework.  It seems to me
like the most natural way to use a class like that would be to pass the
wrapped instance into a constructor.  I guess it doesn't really matter
that much, though.

-- 
Tim Moore / Blackboard Inc. / Software Engineer
1899 L Street, NW / 5th Floor / Washington, DC 20036
Phone 202-463-4860 ext. 258 / Fax 202-463-4863

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message