commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Waldhoff, Rodney" <rwald...@us.britannica.com>
Subject RE: [Collections] primitive pkg - was "Release potential?"
Date Mon, 19 Aug 2002 22:28:11 GMT
-1.

Take a look at IntArrayList and UnsignedShortArrayList.  They share an
interface, but not an implementation, since UnsignedShortArrayList contains
an array of shorts and IntArrayList contains an array of ints.

I think you guys need to take a good hard look at the relationships between
the classes in org.apache.commons.collections.primitives and then suggest a
coherent set of changes, rather than this "no, that's not quite right, let
me add an interface here and a remove a method there" approach.

Naming issues aside, Abstract*ArrayList plays a genuine role here.  Two in
fact, which may be part of the confusion:

A. It defines the common interface for (for example) IntArrayList and
UnsignedArrayList. (i.e., the capacity methods and the "IntList" methods)

B. It implements the forwarding methods (for example, indexOf(Object) to
indexOfInt(int))

Arguably, there are three different abstraction layers here (taking just the
int-based versions for example)

1. The interface IntList, defining the List interface in terms of int
primitives

2. The capacity-based IntList interface (IntArrayList? RandomAccessIntList?)
defining ensureCapacity, capacity, trimToSize, etc.

3. The abstract class that implements the forwarding mehtods

The current implementation combines the second and third layer into
AbstractIntArrayList, and is agnostic to the first layer (i.e., all you have
to do to add that layer is to create IntList and declare
AbstractIntArrayList as implementing it.)

The agile methodologist within me suggests that we may be adding
abstractions prematurely. Is there a use case driving this refactoring?  If
so (and I think I could come up with one) let's make it explicit.

-----Original Message-----
From: Jack, Paul
To: 'Jakarta Commons Developers List'
Sent: 8/19/2002 5:07 PM
Subject: RE: [Collections] primitive pkg - was "Release potential?"

> > Ugh.  Actually what makes the most sense to me is:
> 
> ugh is right.  I should have read your mail before I responded to 
> Rodney's.  I would have just said +1.  :)

Actually, "ugh" has transformed into "ARGH!"

Here's my new suggestion:

class AbstractIntList 
   -- provides the forwarding impls

class IntArrayList extends AbstractIntList
   -- provides the current implementation in IntArrayList

class UnsignedShortArrayList extends IntArrayList 
   -- overrides add/set methods to only allow subrange of ints

Eliminates an abstract class from the mix.  Thoughts?

-Paul


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message