On 24 October 2010 16:26, Rajarshi Guha <rajarshi.guha@gmail.com> wrote:

On Oct 24, 2010, at 3:31 AM, Nina Jeliazkova wrote:
> AFAIK , Vector is still around for compatibility reasons , otherwise
> one could have
> Collections.synchronizedList(new ArrayList())
> http://download.oracle.com/javase/tutorial/collections/implementations/wrapper.html
> Without looking into code and without any particular use in mind, I
> would have preference for collections implementing List<T>
> interface, instead of extending ArrayList<T> class.  This will open
> the door towards using classes from java.util.concurent package,
> e.g. like this one
> http://download.oracle.com/javase/7/docs/api/java/util/concurrent/CopyOnWriteArrayList.html

I think this idea is good, but I'm a little confused. Say RingSet
implemented List<T>, rather than extending ArrayList<T>. The RingSet
class would then have to implement the as much of the List interface
as needed - but the implementation may or may not be thread safe,
synchronized etc. So for each type of List implementation, I'd have to
reimplement RingSet

Not necesarily, you might have one single abstract wrapper, as the one attached in my previous email and only have single method (createList ) that differs.   This could be done with mechanism similar to ChemObjectBuilders, or just anonymous classes.

My motivation for this refactoring was that for the most part the *Set
classes were just lists of objects (with a few helper methods in some
cases). Thus, RingSet is a very slight specialization of List
(ArrayList or any other implementation).

While making RingSet implement List is a nice generalization, I don't
see how it helps us - I'd still have to implement the specific type of
List myself (?) In other words, I'd have to have a traditional
ArrayList based RingSet, a concurrent version of RingSet and so on.

See above.   One could have single wrapper implementation and multiple builders.

In addition, a custom implementation of List interface may not have in-memory implementation at all, e.g. it could retrieve data from online resources on demand, databases, etc. 

Perhaps I am going too far :)
So, why not just have multiple RingSet classes derived from the
specific variants of List implementations:


Less elegant (IMHO ) , more code duplicates and more dependent of actual implementation, thus not easily interchangeable.


The alaternative to all of this is to completely drop RingSet and just
move methods that work on collections of Rings into a manipulator class

Actually, my suggestion is for all classes, implementing set of chemical objects, not specific for the RingSet (but is only a suggestion).

Best regards,

Rajarshi Guha        | NIH Chemical Genomics Center
http://www.rguha.net | http://ncgc.nih.gov
A debugged program is one for which you have not yet found the
that make it fail.
               -- Jerry Ogdin

Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
Cdk-devel mailing list