Right multi object dependance design
Posted
by
kenny
on Programmers
See other posts from Programmers
or by kenny
Published on 2011-12-23T08:18:03Z
Indexed on
2012/03/27
11:38 UTC
Read the original article
Hit count: 320
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?
© Programmers or respective owner