I sometimes find myself thinking what word to use when referring an IEnumerable<Foo>. I don’t think I see a consistent naming when reading.
IEnumerable<Foo>: It’s a type name. It isn’t helpful when thinking or using in a sentence.
Collection: It’s valid but not used everywhere. Although we have the System.Collections namespace.
Sequence: It’s valid too and probably defines it better.
Enumerator or Iterator: They emphasize the operation, rarely used.
What would be the most appropriate one? What do you read it in your code?
An
IEnumerable<Foo>is not an iterator/enumerator – that is a separate concept for the device that iterates it.A collection generally refers to a specific device allowing operations such as add/remove; that does not apply here, but the term is not unreasonable.
Personally I tend to use “sequence” in discussion, but I don’t use that for naming things in the code – I’d just use the thing the sequence represents, i.e. “orders”, “uniqueUsers”, etc – or in the case of generic methods, “items”, “values”, etc.