So I have a Signal class and a client class which manages a list of Signal objects. The class provides a bunch of interfaces, one of them is an update()-function.
The update()-code is completely different for each signal. Thus, one would assume that's a job for derivation.
However, the client manages tens, maybe even a hundred different Signal objects. There is no way I want to have these many child classes.
I'm thinking of introducing a member updateFunction, which is a function pointer type. Now, the client could set this function (maybe via constructor) during the Signal's creation process. Then, the client can call update() for each Signal object and the update()-function would call the function pointer internally.
Would do you suggest? Is there a pattern for this?