Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 8
    Why doesn't Batch simply implement IEnumerable<>? All of these design decisions have already been made 20 years ago for you. Commented Mar 28, 2022 at 10:29
  • @JörgWMittag, you made a very good point. Could you please provide a pseudo-code to make it clear what you meant by your previous comment? Commented Mar 28, 2022 at 11:22
  • What are the specific requirements? A simple IEnumerable should be the default, but more complex solutions might be motivated when dealing with large amount of data, concurrency etc. Commented Mar 28, 2022 at 12:51
  • @JonasH The question is based on the assumption that fetching data in batches leads to shorter processing time overall than fetching then processing them one-by-one. What are you exactly proposing with simple IEnumerable? Commented Mar 28, 2022 at 15:07
  • A simple IEnumerable, as proposed by Jörg and others. But for best efficiency you might want to use a model as close to the underlying data model as possible. Like a Stream or Span<byte> for in-memory data. But it really depends on the type of data, for things like audio or video, efficient handling of buffers can be critical, but in many other cases the overhead of calling a method is irrelevant. Manual batching like that might be relevant when fetching data from some web API. Commented Mar 28, 2022 at 15:35