Patterns for large resultsets of repositories - ideas?

Mirko Sertic <[email protected]>
Newsgroups gmane.comp.programming.domain-driven-design
Message-ID <[email protected]>
Hi there

 From an OO point of view, what would be the best option to implement 
large resultsets of repositories, for instance a few hundred objects 
returned by a search operation? I want to implement some kind of 
iterator pattern to fetch entities one by one. This should avoid an out 
of memory problem, but will also introduce side effects with unexpected 
behavior, like an open and probably not safely closed database cursor. 
Introducing a "close" method on the iterator would also introduce some 
kind of leakage into the API, and the caller must be aware of closing 
the iterator in every case. An other option would be to fully iterate 
over the whole resultset, and the iterator implementation will free 
resources after the last entry was fetched. But the caller might not 
want to iterate the whole resultset. The last option would be to use a 
destructor/finalizer to free up resources, but in a managed environment, 
their execution cannot be predicted, so we would again have some strange 
side effects as the worst case.

Any ideas?

Thanks in advance

Mirko


------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.