commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jack, Paul" <pj...@sfaf.org>
Subject RE: [Collections][SUBMIT] TypedList
Date Thu, 25 Apr 2002 16:44:25 GMT
> I agree.  I think one of the benefits of the Proxy pattern is that one
> proxy can be wrapped inside another.  So PredicatedList and
> TransformingList would be separate classes, since they represent two
> different responsibilities.  If you want to do both, put one inside the
> other.

I agree here too.  Having them in separate classes would also allow me
to control what order things happen in:

new PredicateList(new TransformList(transform, list), predicate)
new TransformList(new PredicateList(predicate, list), transform)

The above could do different things.  If I predicate first, I can strip
out illegal values to my transform; or, I might be using a transform
that can produce null values that I don't want stored in my list, so 
I'd predicate afterwards; or both; I think this is a much more flexible
pattern.

Having said all that, I think we should keep in mind that if we want to
be complete, we're talking about adding fourteen new classes:

PredicateBag
PredicateCollection
PredicateList
PredicateMap
PredicateSet
PredicateSortedMap
PredicateSortedSet
TransformBag
TransformCollection
TransformList
TransformMap
TransformSet
TransformSortedMap
TransformSortedSet

Seems like a lot to include in the public API.  Instead I'd advocate doing
what java.util.Collections does; have one class (maybe WrapperUtils? Or
maybe
within CollectionUtils?) that provides static methods for returning wrapped
collections:

  public static List predicateList(List list, Predicate predicate);
  // other fourteen similar methods...

We could then hide the fourteen implementation classes either by making them
inner classes of WrapperUtils or by giving them package scope.

Having the classes themselves exposed in the public API seems wasteful, as 
they're difficult to subclass (unless we also expose the sublist, submap,
collection view and iterator classes -- dozens more) and are meant for 
composition.

-Paul



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