Right multi object dependance design
- by kenny
I need some help with a correct design.
I have a class called BufferManager. The push() method of this class reads data from a source and pushes it to a buffer repeatedly until there is no more data left in the source.
There are also consumer threads that read data from this buffer, as soon as new data arrives.
There is an option to sort the data before it comes to buffer. What I do right now is that BufferManager, instead of pushing data to the buffer, pushes it to another "sorting" buffer and starts a sorting thread. SorterManager class reads the data, sorts it in files and push()es the sorted data into the buffer.
There will be a bottleneck (I use merge sort with files) but this is something I can't avoid.
This is a bad design, because both BufferManager and SorterManager push data to a buffer (that consumers read from). I think only BufferManager should do it.
How can I design it?