I am puzzled on how to model this situation.
Suppose you have an algorithm operating in a loop. At every loop, a procedure
P must take place, whose role is to modify an input data
I into an output data
O, such that
O = P(I).
In reality, there are different flavors of
P3 and so on. The choice of which
P to run is user dependent, but all
P have the same finality, produce
This called well for a base class
PBase with a method
PBase::apply, with specific reimplementations of
P3::apply(I). The actual
P class gets instantiated in a factory method, and the loop stays simple.
Now, I have a case of
P4 which follows the same principle, but this time needs additional data from the loop (such as the current iteration, and the average value of
O during the previous iterations).
How would you redesign for this case?