Iterator is the worst thing that ever happened to the Collections API (because of its
omnipresence, not its presence).  I think it's way overused because people have talked 
too much
about how it's a simple generic abstraction.  The fact is, it's very often the case in 
use of a
data structure that you want to get the elements in a less restrictive way than 
Iterator provides.
 When was the last time you called a HashMap's keySet().iterator() method in order to 
find the
thing you were looking for?  Why do ArrayLists exist in the first place?  Iterators 
suck in a lot
of respects, because you have to create a new object for every pass over some data 
that's already
wrapped up in (usually a lot of) objects, and you incur extra performance penalty for 
every all
those method calls.  This stuff really adds up.

I would try to avoid any but forward-only or backward-only reads in my own database 
programming,
but it's sometimes necessary to look at a value previously returned from a ResultSet.  
The best
schemes don't rely on the result set itself, but cache stuff that will be needed 
later.  The way
the method is implemented, EVERYTHING is cached in memory already, and the fact that 
you get an
Iterator back doesn't change that, it only restricts your ability to index into the 
data.  You
also lose the ability right off the bat to know how many rows were returned, even 
though
everything is sitting right in memory.

Jeff

--- Henri Yandell <[EMAIL PROTECTED]> wrote:
> 
> initial capacity, +1.
> 
> Iterator will need arguing. I don't believe people need to get collections
> back from an API, they need the lowest common denominator and my view is
> that this is an iterator.
> 
> It's something that always starts arguments though :)
> 
> Hen
> 
> On Thu, 21 Nov 2002, Jeff Varszegi wrote:
> 
> > Looks okay, except I think you should make the initial capacity of the ArrayList 
>bigger
> perhaps.
> > I don't know.  Also, I would way rather have the ArrayList for my database-lookup 
>trouble than
> > some ListIterator that I can only use once.
> >
> > My 1.5 cents,
> >
> > Jeff
> >
> > --- Eric Alexander <[EMAIL PROTECTED]> wrote:
> > > Here's a patch to DBUtils that adds an executeQuery method:
> > >
> > > public static Iterator executeQuery(Connection connection, String query,
> > > Object[] vals) throws SQLException
> > >
> > > If null is found in the Object[], it will get passed to the driver. There's
> > > probably something better we can do with it, but it's a start.
> > >
> > >
> >
> > > ATTACHMENT part 2 application/octet-stream name=DbUtils.patch
> > > --
> > > To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> > > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> >
> >
> > __________________________________________________
> > Do you Yahoo!?
> > Yahoo! Mail Plus � Powerful. Affordable. Sign up now.
> > http://mailplus.yahoo.com
> >
> > --
> > To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> >
> >
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus � Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

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

Reply via email to