March 14th, 2013, 10:03 AM
Configurable step selection in Strategy pattern
I have a component that provides some functionality to multiple clients. This functionality is broken down into a sequence of steps. The use of strategy pattern seems like a good idea.
It is very important to keep the interface to the clients stable while changes in the component might occur.
I want to make it possible to have interchangeable step implementations that the clients can choose. But for example if a new step implementation is created, I do not want to change the interface of the component, to make the new class implementing the step available because that would require all my existing clients to be rebuild and tested.
My question is how to allow the client to choose the step implementations without knowing the implementing classes? Would a configuration parameter (string or int) when calling the component and class creation in an if block suffice? It does not sound very elegant solution...