The iterator pattern is very clearly defined. What would you call the consumer of an iterator?
3
My comment was to say that I’d call the class an “aggregator,” and I’m putting it here as requested. I’d also like to respond to the comment suggesting that the results aren’t always aggregated, presumably in the sense of totaling up some kind of value.
What I mean with “aggregate” is the qualitative dictionary definition of the term: “taking all units as a whole.” This doesn’t necessarily mean that each record has some integer property and the total of that property is the aggregate. Rather, I’d consider the “aggregate” to be the interpretation of the the big picture. You’re considering a sequence of these things as part of some larger gestalt (i.e. “as a whole,” in whatever sense that means to you.)
2
One reason you may need to ask is that the original Gang of Four book describing the iterator pattern refers to the consumer of an iterator with the highly distinctive name of “client” (and in fact later on it doesn’t show the client as one of the participants in the pattern at all).
I don’t know of any specific jargon for the consumer of an iterator, and would guess that no standard name has been settled on.
Iteratoror comes to mind, but I don’t expect it to catch on.
You just said it – the consumer of an iterator (or the client). 🙂 This is the language used in this reference and elsewhere.
In agreement with Erik’s answer, the way to name the consumer (IMO) is to imply iteration with a term like aggregate
/ sum
/ iterate
or even just use a plural (e.g. GetCustomers
). Yet describing its business purpose is probably more important than calling out the fact that it is iterating (again IMO).
3
Iterable
. An Iterable
uses an Iterator
to iterate its elements. Hence it is consuming the iterator .
3
Despite that “aggregator”, “IteratorClient” & “IteratorConsumer” seems to match the idea, I suggest to “highlight” the goal of your class, as your class identifier.
.............................
..+-----------------------+..
..| ArrayListClass |..
..+------*----------------+..
.........*...................
..........*..................
...........*.................
............*................
............*................
..+----------*--------+......
..| /......
..| Has Iterators /.......
..| / |......
..+----------------/--+......
.............................
One exception, that I have to deal with, is that you have a class, without iterators, and you make a subclass, with the only goal of adding iterators, and you cannot or do not want to add the iterators to the original class.
.............................
..+-----------------------+..
..| TreeViewClass |..
..+-----------*-----------+..
..............|..............
..............|..............
..............|..............
..............^..............
............./..............
............/...............
.........../--*--...........
..............|..............
..............|..............
..............|..............
..+-----------*-----------+..
..| IterableTreeViewClass |..
..+-----------------------+..
.............................
Cheers
2