Parametrized Strategy Pattern
- by ott
I have several Java classes which implement the strategy pattern. Each class has variable number parameters of different types:
interface Strategy {
public data execute(data);
}
class StrategyA implements Strategy {
public data execute(data);
}
class StrategyB implements Strategy {
public StrategyB(int paramA, int paramB);
public data execute(data);
}
class StrategyB implements Strategy {
public StrategyB(int paramA, String paramB, double paramC);
public data execute(data);
}
Now I want that the user can enter the parameters in some kind of UI. The UI should be chosen at runtime, i.e. the strategies should be independent of it. The parameter dialog should not be monolithic and there should be the possibility to make it behave and look different for each strategy and UI (e.g. console or Swing).
How would you solve this problem?