Processing a stream. Must layers be violated?

Posted by Lord Tydus on Programmers See other posts from Programmers or by Lord Tydus
Published on 2012-10-05T01:01:20Z Indexed on 2012/10/05 3:51 UTC
Read the original article Hit count: 172

Filed under:

Theoretical situation:
One trillion foobars are stored in a text file (no fancy databases). Each foobar must have some business logic executed on it. A set of 1 trillion will not fit in memory so the data layer cannot return a big set to the business layer. Instead they are to be streamed in 1 foobar at a time, and have business logic execute on 1 foobar at a time. The stream must be closed when finished.

In order for the stream to be closed the business layer must close the stream (a data operation detail), thus violating the separation of concerns.

Is it possible to incrementally process data without violating layers?

© Programmers or respective owner

Related posts about layers