I am running in the exact problem Robert Martin mentioned when having a class named Manager
, mine has too much (redudant) code.
I am writing a system doing computations on many buffers containing data form a timestamped source.
- The Buffers store different data types, they are template classes.
- When a new Observation arrives, a
BufferManager
distributes and processes fields of the Observation to the different Buffers. - A common user operation is to access a time interval of a given buffer.
I have a BufferID
emum of names in the BufferManager
, one for each Buffer
and then I have dictionaries (std::map) in the BufferManager
, one for each type of Buffer.
The user then gets a desired interval of a Buffer by calling:
Type1Interval int1 = BufferManager.getType1BufferInterval(BufferID, starTime, endTime)
...
TypeNInterval intN = BufferManager.getTypeNBufferInterval(BufferID, starTime, endTime)
where the only difference between two such functions is that getTypeJBufferInterval accesses the dictionary containing buffers of type J.
How can I, given a BufferID
and a time interval, return the corresponding Buffer(values) without having to have all these different functions?