If I am writing .NET code I would often expose IEnumerable
where-ever it could possibly make sense. Maybe it was down to LINQ and the fact you could us
Whether or not you want to be a Stream
yourself, primarily depends on whether you're truly a Stream
with the corresponding powers, i.e. support parallelization (not all Stream
s do, but it's one of the many benefits of Stream
s, and it's an important one). Normally I'd rather be a Collection
and let myself be Stream
ed by the corresponding API calls.
The getStuff()
method, returning Stream
from myCollection.stream()
looks right to me.