2

Imagine a subclass of Collection that knows a select block and a collect block. An instance of this class wraps another collection and dynamically applies to it these blocks. So, for instance, #do: is implemented as

do: aBlock
    collection
        select: [:element | select value: element]
        thenDo: [:element | | v |
            v := collect value: element.
            aBlock value: v]]

So, the question is how should I name this class? I've called it WrappedCollection but this name is ambiguous and, besides, this thing must already exist and have a name.

By the way, this is very similar to Subclassing Stream, except that mine is not a Stream.

Community
  • 1
  • 1
Leandro Caniglia
  • 14,495
  • 4
  • 29
  • 51

2 Answers2

1

The select and collect blocks sound to me like condition criteria. So maybe you could name the class ConditionalCollection, implying that the collection changes in response to the conditions that are being applied.

And another idea I just had: FilteredCollection.

Max Leske
  • 5,007
  • 6
  • 42
  • 54
1

We've finally decided to use DerivedCollection. Given that these objects represent collections obtained from other sources, much as mathematical sets can be defined by intention rather than extension, we picked a name that doesn't reveal their internal representation.

BTW, DerivedCollections are specially useful for filtering (#select:) and transforming (#collect:) large amounts of data which we represent with instances of StoredArray, a kind of Array that stores its elements on disk.

Leandro Caniglia
  • 14,495
  • 4
  • 29
  • 51