Design pattern for fetching data in chunks

datadata structuresdesign-patternsobject-oriented-designqt

I am creating Qt application that uses database with huge amount of data to draw some charts. Fetching data from the database is time consuming, so is blocking the application thread or worker thread creating an unpleasant delay.

I have an idea that instead of doing everything at once I can fetch data and draw charts in chunks. How would I design this functionality?

I have no idea how can I design my interfaces. I want also want there to be a place for other database stuff, like caching, in clean way.

Best Answer

Have a look at the Batch Iterator (or Chunky Iterator) Pattern from POSA5 (chapter 6.3). There is also a book if you want more detail.

Assuming you understand the Iterator pattern, the batch iterator does the chunking based on the size of the data structure it uses (the iterator's client is unaware of how chunking occurs).

Related Topic