On Mon, Jan 24, 2011 at 7:49 AM, Jody Garnett <[email protected]> wrote:
> I was wondering why it was chosen not to derive the interface of
> FeatureCollection from the general Collection interface in java, as it
> implements all the same methods.
>
> To answer that question - we did derive from java.util.Collection - however
> when we moved to Java 5 - the language started assuming what it could do
> with a collection. Specific the "for each" loop syntax did not match with
> out need to "close" an iterator after it was no longer used.
> We tried some workaround such as:
> for( Feature feature : featureCollection ){
>    System.out.println( feature.getID() );
> }
> featureCollection.purge(); // to clean up any open iterators
> But as you can see above the idea was not thread safe.

It's not only about thread safety. A collection is an intermediary to data
access, as such it should throw some sort of IOException at every step,
otherwise people would just use it as if it was an in memory one
forgetting about handling those errors.

Also, we have one million feature collection implementations, and the
interfaces of Collection is very large, so we ended up finding a lot of
duplicated effort.

Having an explicit close method is a good step forward, not having
the IOExceptions around is something that is still source of many
issues as people forget they are really playing with databases, files
and remote server connections

Cheers
Andrea

-- 
Ing. Andrea Aime
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054  Massarosa (LU)
Italy

phone: +39 0584962313
fax:     +39 0584962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf

-----------------------------------------------------

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to