commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henri Yandell <bay...@generationjava.com>
Subject Re: [DBUtils][patch] executeQuery method
Date Fri, 22 Nov 2002 08:37:49 GMT


On Thu, 21 Nov 2002, Jeff Varszegi wrote:

> > What do you recommend on initial capacity
>
> I dunno, 50 or 100 would be nice.  That's still a small result set
> size, and reduces copying a lot since I think that ArrayList defaults
> to 10 capacity, like most array-based structures in Java.
>
> > In this case, due to the nature of closing the ResultSet underneath,
> it is > unlikely the Iterators chief promise of lazy loading can be
> fulfilled
>
> Right!
>
> > should provide a common API. That
> > common API should have common ins and outs and Iterator is more generic
> > than a particular List, Map or Set
>
> I operate under two basic rules when I think about this sort of thing:
> 1. You should try to make things generic
> 2. You should never throw
> away (too many) useful things in the course of making something
> generic.
>  If you had to, it means your abstraction is too generic for
> application in the domain, or needs to sit on top of another
> less-generic abstraction that provides more detailed support for when
> you'll need it

List has functionality which doesn't make sense in the context. Add,
remove, contains.

So a big 3) in your list is:

3) You should not offer up a partial API [ie) all the crap in Java with
'optional' methods. Iterator.remove etc.]

> > 1) ListIterator and not Iterator. We have a List, why not use it, as
> you said.
>
> That's a really good idea!  All your comments are well-thought.

Basically I think that I need to have an ExtendedListIterator.

IteratorUtils.makeExtendedListIterator( List list ) {
    return new ExtendedListIterator( list.iterator(), list.size() );
}

That is, if ListIterator just knew the size [and why can't it know that!
stupid API] then I'd feel secure to sit in a high castle shouting for
Iterators. :)

Maybe I can convince people that it could be in Collections.

Hen


--
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